You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gist 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 <family name>, <given name> (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.
After messing around with ValidationError for a bit, it came to my knowledge that it has a json() method that outputs a str representation of the error. You can get the location of the error from the loc field.
This gist 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 aPerson
contributor should be in the form of<family name>, <given name>
(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 dandi/dandi-archive#713 and then more recently from dandi/dandi-archive#1958. @mvandenburgh has filed #245 (and #244) to deal with Pydantic's default algorithm for validating
Union
s; this issue has more to do with improving error messages across the board.The text was updated successfully, but these errors were encountered: