I'm using Cerberus version 1.1.
The Cerberus required
validation rule appears to default to False
, with the result being that an empty document is perfectly valid.
>>> schema = {
'spam': {'type': 'string'}
}
>>> v = Validator()
>>> v.validate({}, schema)
True
But I have a very lengthy schema document which needs to be strictly enforced. Is there a way to default to 'required': True
for the entire schema, such that every defined field is required?
As it stands, I seem to have to paste 'required': True
into every field definition, which seems needlessly redundant.
Sure, you can use simple Python idioms to design your schema: