Cerberus is a lightweight and extensible data validation library for Python
Cerberus provides powerful yet simple and lightweight data validation functionality out of the box and is designed to be easily extensible, allowing for custom validation. It has no dependencies and is thoroughly tested from Python 2.6 up to 3.5, PyPy and PyPy3.
At a Glance
You define a validation schema and pass it to an instance of the Validator class:
schema = {'name': {'type': 'string'}}
v = Validator(schema)
Then you simply invoke the validate()
to validate a dictionary against the schema. If validation succeeds, True
is returned:
document = {'name': 'john doe'}
v.validate(document)
True
Documentation
See the Cerberus website.