Add context
field to ValidationError
, to improve oneOf and anyOf validation errors
#649
Labels
context
field to ValidationError
, to improve oneOf and anyOf validation errors
#649
In the case where no subschema is valid, the ValidationError instances in python-jsonschema set a
context
attribute for allOf and anyOf validation errors as documented and in the code.This
context
attribute contains all the validation errors from the subschemas. This is very useful, because the default error message is not sufficiently informative: "[frequently a very large JSON blob] is not valid under any of the schemas listed in the 'oneOf' keyword".Instead, an application could report the specific errors under each of the subschemas (or, it could have some way to determine which subschema was most relevant, and only report its errors). It might then end up reporting a single, specific validation error within the subschema, which is much more actionable. For example, "'name' is not a string".
Adding this sort of
context
attribute (I have no opinion on naming) would allow applications to improve the error message.The text was updated successfully, but these errors were encountered: