Validate dicts in Python

i looking for tool, or examples to/how to validate dictionaries in python. For example, i have dict:

test = {'foo' : 'bar', 'nested' : {'foo1' : 'bar1', 'foo2' : 'bar2'} }

And now i must validate it. Lets say, value for key foo must be boolean False or non-empty string. Next, if key foo1 have value bar1, that key foo2 must be int in range 1..10. I wrote simple function to do this, but this is not what i exactly want. Yea, sure, i can test every single item in dict with if..else, but if dict have >50 elements, then it is a bit not comfortable.

Is there any good tool/lib to do this in Python? I not looking for parsers, only fast and effective way to do this right.


Voluptous is a nice tool that does this

You can also try the link below: Its a great package that helps in validation in an easier way

I highly recommend Cerberus for its readability or jsonschema because it uses the JSON Schema standard

Webster is a pypi package that does dictionary validation and value regex validation.. this allows you to insure that the dictionary has all the keys its supposed to and the values are more or less what you would expect.

Need Your Help

playframework owasp top 10

java security scala playframework owasp

I'm thinking about using Play for a large-scale project, so, has anyone battle-tested Play framework for OWASP Top 10? Are there any security problems you know of in Play framework?

Can the :not() pseudo-class have multiple arguments?

css css3 css-selectors

I'm trying to select input elements of all types except radio and checkbox.