Return multiple validation errors at once
See original GitHub issueNot sure if it’s possible, but it would be useful if you could get a list of e.g. ValueError
s, rather than just the first one that failed when there are multiple issues.
It would make typical
much more useful for validation purposes.
Perhaps it could be configured somehow which behavior you want, since there could be a performance hit, I suppose.
Example:
>>> @typic.al
... @dataclass
... class N:
... a: str
... b: int
... c: int
...
>>> N(a="a", b="a", c="b")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 3, in __init__
File "../typic/api.py", line 143, in __setattr_coerced__
value = ann[name](value) if name in ann else value
File "../typic/coercer.py", line 117, in coerce
return self.coercer(value)
File "<string>", line 3, in coerce__class_int___class_inspect__empty__False
ValueError: invalid literal for int() with base 10: 'a'
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to return multiple validation errors? · Issue #1038 - GitHub
I want connexion to send response with an array of validation errors rather than a message which contains only one error message even...
Read more >Validation that returns more than 1 error - Stack Overflow
The errors value is created by making a List of Option values, one for each validation check. The flatten method extracts the contents...
Read more >A Better Way to Handle Validation Errors - Kevin Smith
Another common technique is to bundle up all the validation errors and return them in some sort of payload—an array, a custom Errors...
Read more >How to report multiple errors as a result of validation?
In Java you would make errors and warnings members of ValidationResult and would write hasErrors and hasWarnings and getErrors and getWarnings resp. addErrors ......
Read more >Display all validation rule errors at once - IdeaExchange
It would be a better user experience if validation rule error messages would appear at once instead of one by one after you...
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 Free
Top 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
You read my mind. It’s a bit of expansion in scope for the constraints validator, but work is ongoing in the
v2beta-validator
branch to provide “strict” validation of inputs automatically.@syastrov -
Thanks for the honesty there. Error-chaining should be possible.
I’d put it at a medium-heavy lift, as the current system is really designed to short-circuit ASAP with an informative error. It’s not impossible to add a branch for this, but definitely a day or two’s worth of work, which is why I’m scheduling it for 2.1.