I'm trying to validatie the following doc.
document = {
'days': {
'Monday': [{
'address': 'my address',
'city': 'my town'
}],
'Tuesday': [{
'address': 'my address',
'city': 'my town'
}]
}
}
Using the following schema.
schema = {
'days': {
'type': 'dict',
'allowed': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
'schema': {
'type': 'list',
'schema': {
'address': {
'type': 'string'
},
'city': {
'type': 'string', 'required': True
}
}
}
}
}
v = Validator(schema)
if not v.validate(document, schema):
raise Exception("Configuration file is not valid", v.errors)
I get the following error: {days: ['must be of dict type']}
I cannot figure out how to validate the dict that is contained within the list.