question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improvements to Validation API!

See original GitHub issue

This is issue is for suggesting improvements to the Javalin’s validation API (Validator/Rule classes)

To consider:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:33 (31 by maintainers)

github_iconTop GitHub Comments

1reaction
MrThreepwoodcommented, Jun 2, 2021

I’ll take a stab at adding something. I think the fundamental difference here is that you see args as some extra unrelated thing. I see the args as part of the error. The error returned from a check is not just a string, it is a string and a map/array of args. It doesn’t make any more sense to me to add the “args” for an error to the request attributes than it would to add the message. The message and the args go together. If the message is stored in the validator, the args should be stored in the validator.

I think I can add it in such a way that most users of the API won’t know the difference. I would still prefer that the predicate return the error rather than passing a predicate and a error separately, as it would allow for sane default errors from standardized validation checks, but I’ll just keep it to Adding the args for now.

1reaction
MrThreepwoodcommented, Jun 2, 2021

The point is that you really can’t format the error after retrieving it from the validator. During validations, you have to tell the validator: check("start_date", { it > some_date && it < some_other_date }), “here’s an error”)`. This then fails, so you can now format it in the exception handler for validation errors, but what were the dates? How do you access them? You need to provide it to the front ends in the format I’ve described previously, so how do you do that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 good ways to validate APIs
Development teams might consider test-driven development (TDD) methodologies to validate and prototype with APIs.
Read more >
Improving Validation Errors in API Clients
Announcing several improvements related to dealing with validation errors in our API clients.
Read more >
Email Address Validation API: How To Get More Results
1. Better Customer Engagement: · 2. Verifying Quality of Leads · 3. Constructing Quality Email Addresses · 4. Productivity Improvements.
Read more >
What is API validation - a guide
API validation is the process of checking to see if an API meets certain requirements for how it works, how well it performs,...
Read more >
Guidance 023 Evaluation of Changes for Potential Impact ...
Validation required for rework processing that provides an API, but may not be required for an intermediate process step of an API manufacturing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found