I have a data structure that looks like this with name
being an
arbitrary string that cannot be certain values (src
)
{
'name' : 'stringvalue',
'src' : 'who cares this is wrong'
}
I'd like cerberus to check that the keys are anything but src
or alsoBad
, but all the schema examples I see seem to require that I specify the format for a given name.
I've tried this:
def check_data(type_data):
val = cerberus.Validator()
val.allow_unknown={'forbidden' : ['src','alsoBad']}
val.validate(type_data,{})
With the thought that the empty schema would cause the allow_unknown
to go to work. But this does not find the problem.
Then I tried:
def check_data(type_data):
val = cerberus.Validator()
val.allow_unknown=
val.validate(type_data,{'any_field':{'forbidden' : ['src','alsoBad']}})
But this also failed to catch the problem.
How do I check the first level keys in a dict when they could be anything?