Use full information from `ValidationError` to form error messages
- Dominant language
- Python
- Stars
- 7
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
[This gist](https://gist.github.com/waxlamp/5966f1d2290c218f5fc51354b01069ca) demonstrates how Pydantic validation errors can indicate the exact value within the "tree" of values caused a failure, its location, and a machine-readable error type. This information could be used to immediately improve validation error messages (by just including the value and location).
A longer-term improvement would be to use the machine-readable tag plus the field name to "translate" "nerd" messages ("This string failed to match this regex") into "end user" messages ("The `name` field of a `Person` contributor should be in the form of `, ` (some examples: `Doe, Jane`; `Picard, Jean-Luc`; `Hornblower, Horatio`").
I plan to send a proof-of-concept PR demonstrating one way `dandischema` could accomplish this.
This issue originated from https://github.com/dandi/dandi-archive/issues/713 and then more recently from https://github.com/dandi/dandi-archive/issues/1958. @mvandenburgh has filed #245 (and #244) to deal with Pydantic's [default algorithm for validating `Union`s](https://docs.pydantic.dev/latest/concepts/unions/#smart-mode); this issue has more to do with improving error messages across the board.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.