I need to validate dictionary received from a user
the problem is that a field can be both dictionary and list of dictionaries. How i can validate that with cerberus?
Like a example i try this schemas:
v = Validator(
{
'v': {
'type': ['dict', 'list'],
'schema': {
'type': 'dict',
'schema': {'name': {'type': 'string'}}
}
}
}
)
But when I try it on a test data, I receive error:
v.validate({'v': {'name': '2'}}) # False
# v.errors: {'v': ['must be of dict type']}
Error:
{'v': ['must be of dict type']}