Improvements to Validation API!
See original GitHub issueThis is issue is for suggesting improvements to the Javalin’s validation API (Validator
/Rule
classes)
To consider:
- Allow Nullable Types to Be Processed By Validator (https://github.com/tipsy/javalin/issues/991)
- Allow custom validation errors and validation rules overriding (https://github.com/tipsy/javalin/issues/993)
- Add validator method returning default value (https://github.com/tipsy/javalin/pull/835)
Issue Analytics
- State:
- Created 2 years ago
- Comments:33 (31 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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?