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.

Return multiple validation errors at once

See original GitHub issue

Not sure if it’s possible, but it would be useful if you could get a list of e.g. ValueErrors, 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:open
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
seandstewartcommented, Nov 30, 2019

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.

0reactions
seandstewartcommented, Jun 17, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

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