-
Notifications
You must be signed in to change notification settings - Fork 241
Closed
Milestone
Description
Used Cerberus version 1.3
Bug report / Feature request
Depreciation of the rule keyschema and valueschema does not work properly when in a subschema of valueschema or keyschema on itself:
This snipet will not work for instance:
schema = {
"a": {
'type': 'dict',
'valueschema': {
'type': 'dict',
'keyschema': {
'type': 'string',
},
'valueschema': {
'type': 'string'
},
}
}
}
cerberus.Validator(schema)Output will be:
(BackEnd) moutix@pistache ~/project/BackEnd (*feature/cerberus-upgrade) $ python testcerberus.py
Traceback (most recent call last):
File "testcerberus.py", line 36, in <module>
cerberus.Validator(schema)
File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/validator.py", line 181, in __init__
self.schema = kwargs.get('schema', None)
File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/validator.py", line 562, in schema
self._schema = DefinitionSchema(self, schema)
File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/schema.py", line 76, in __init__
self.validate(schema)
File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/schema.py", line 247, in validate
self._validate(schema)
File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/schema.py", line 263, in _validate
raise SchemaError(self.schema_validator.errors)
cerberus.schema.SchemaError: {'a': [{'valuesrules': [{'keyschema': ['unknown rule'], 'valueschema': ['unknown rule']}]}]}
When setting with valuesrule, it will properly work:
import cerberus
schema = {
"a": {
'type': 'dict',
'valuesrules': {
'type': 'dict',
'keysrules': {
'type': 'string',
},
'valuesrules': {
'type': 'string'
},
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels