Skip to content

Standard Validation Exception #1152

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

Closed
BEllis opened this issue Jun 23, 2023 · 2 comments
Closed

Standard Validation Exception #1152

BEllis opened this issue Jun 23, 2023 · 2 comments

Comments

@BEllis
Copy link

BEllis commented Jun 23, 2023

Currently validators seem to raise a plethora of exceptions of different types and often don't prove much structured info regarding the error.

When a validation exception is raised, I'd expect to be able to determine,

  • data class type
  • data class instance
  • attribute (and/or path?)
  • validiator instance/function
  • value
  • reason for the validation failure or caused by exception

So I can provide useful and structured validation errors to clients of my library/application.

This is partially covered with cattrs and the ClassValidationError exception (and related classes) perhaps porting those exceptions from cattrs or attrs would be a good start?

.

@BEllis
Copy link
Author

BEllis commented Jun 23, 2023

I've just found valid8 that fulfills my requirement. Would be nice if this was a first-class thing but happy to close if contributors disagree.

@hynek
Copy link
Member

hynek commented Jul 9, 2023

This is specifically what cattrs is for. With attrs we try to provide you with a toolkit that builds classes as close to what you'd write yourself and leave automation on top of our hooks and metadata to other packages – most famously cattrs. Some older bits and pieces are arguably past that line, but we're trying to keep the two planes separate.

@hynek hynek closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2023
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

2 participants