-
-
Notifications
You must be signed in to change notification settings - Fork 602
Closed
Description
It seems that error.schema_path always refers to a path in the full schema, whilst error.schema may only be a subschema fragment. This makes it hard (impossible?) to use error.schema_path to index into the relevant schema.
from jsonschema import Draft4Validator as Validator
schema = {
'type': 'object',
'properties': {
'a': {
'type': 'object',
'properties': {
'nested': {
'type': 'string',
'pattern': '^hello$'
}
}
}
}
}
errors = Validator(schema).iter_errors({'a': {'nested':'world'}})
for error in errors:
print error.schema_path, error.schema
# deque(['properties', 'a', 'properties', 'nested', 'pattern']) {'pattern': '^hello$', 'type': 'string'}Note: For my purposes it would be more useful to access the full schema from the error rather than constrict the schema_path.
Metadata
Metadata
Assignees
Labels
No labels