Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured error from Constraint on invalid input #394

Open
mih opened this issue Oct 18, 2022 · 1 comment
Open

Structured error from Constraint on invalid input #394

mih opened this issue Oct 18, 2022 · 1 comment

Comments

@mih
Copy link
Member

mih commented Oct 18, 2022

Right now, a constraint will merely error on invalid input, typically with a ValueError.

For more complex constraints (nested, alternatives), the reason for an "invalid" response can be difficult to decode. Moreover, it is impossible to associate an error with a particular input component, in case of validating a structured data input.

An exception needs to be enhanced with enough information to pinpoint the reason for a validation failure -- enough to be able to annotate the respective component of an input form with a targeted error message.

CC @jsheunis

@mih
Copy link
Member Author

mih commented Oct 28, 2022

Pydantic's ValidationError readily provides this kind of information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant