-
-
Notifications
You must be signed in to change notification settings - Fork 611
support for validating entire structure rather than throwing ONLY the first validation error found #515
Copy link
Copy link
Closed
Labels
InvalidNot a bug, PEBKAC, or an unsupported setupNot a bug, PEBKAC, or an unsupported setup
Description
Would it be possible to add a flag to validate so that all the schema errors are found and included in the error? and in the error object itself, would be excellent to include a list of all the errors so can easily iterate over rather than having to parse the error message.
here for example I have 2 errors in schema
from jsonschema import validate
schema = {
"type" : "object",
"properties" : {
"price" : {"type" : "number"},
"name" : {"type" : "string"},
},
}
try:
validate({"name" : 3, "price" : '34.99'}, schema)
except Exception as e:
#import pdb; pdb.set_trace();
breakpoint();
raise
but am prompted for only the first one
jsonschema.exceptions.ValidationError: '34.99' is not of type 'number'
Failed validating 'type' in schema['properties']['price']:
{'type': 'number'}
On instance['price']:
'34.99'
I do not see this one until the first one is fixed;
Failed validating 'type' in schema['properties']['name']:
{'type': 'string'}
On instance['name']:
3```
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
InvalidNot a bug, PEBKAC, or an unsupported setupNot a bug, PEBKAC, or an unsupported setup