Open
Description
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:
from jsonschema import Draft4Validator as Validator
schema = {
'type': 'object',
'properties': {
'a': {
'type': 'string'
},
'b': {
'type': 'string',
'pattern': '^hello$'
}
},
'required': ['a', 'b']
}
errors = Validator(schema).iter_errors({'b': 'world'})
for error in errors:
print error.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?