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
required, additionalProperties, propertyNames, dependentRequired and any other validators that reference property *names* need a way to indicate the erroring names in ValidationErrors #119
Trying to figure out if there is a way to retrieve the name of a missing required property from an error (without hacking it out of error.message).
For example:
fromjsonschemaimportDraft4ValidatorasValidatorschema= {
'type': 'object',
'properties': {
'a': {
'type': 'string'
},
'b': {
'type': 'string',
'pattern': '^hello$'
}
},
'required': ['a', 'b']
}
errors=Validator(schema).iter_errors({'b': 'world'})
forerrorinerrors:
printerror.path, error.schema_path, error.message# deque([]) deque(['required']) 'a' is a required property# deque(['b']) deque(['properties', 'b', 'pattern']) 'world' does not match '^hello$'
In error.path and error.schema_path there is no mention of 'a'. Is there a way to determine that the property missing was 'a' without using error.message?
mnowotnik, colidyre, vHanda, Scandiravian, niksabaldun and 8 more