-
-
Notifications
You must be signed in to change notification settings - Fork 603
Closed
Description
It seems this package is using custom types for both instance and schema. This is making a problem for me because I have instances which are immutable objects (I use tuples instead of lists, and frozendict instead of dicts) and I would like to validate them against a JSON schema which are normal dicts and lists. But this does not seem possible because code uses things like: validator.is_type(items, "object") to check if schema is describing an object or not, but if object is a frozendict, this breaks validation. Even if my schema itself passed validation.
Example.
import frozendict
import jsonschema
schema = {
'type': 'object',
'properties': {
'tags': {
'type': 'array',
'items': {
'type': 'string'
}
}
}
}
jsonschema.Draft4Validator.check_schema(schema)
validator = jsonschema.Draft4Validator(
schema=schema,
types=dict(jsonschema.Draft4Validator.DEFAULT_TYPES, **{
'array': tuple,
'object': frozendict.frozendict
})
)
validator.validate(frozendict.frozendict({'tags': ('foobar',)}))Metadata
Metadata
Assignees
Labels
No labels