Questions tagged [cerberus]

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.

127 questions
0
votes
1 answer

Python Eve: document-level validation

We've used field-level validation quite a bit and it is wonderful and powerful. There are times, though, the document itself is valid only by assessing more than one field. Changing any field involved must trigger the validation. What we've done…
biscuit314
  • 2,384
  • 2
  • 21
  • 29
0
votes
2 answers

How can I validate a field depending on the lenght of another field with Cerberus?

Is there a way to validate document where existence of one field depends of length of other field? My try: import cerberus schema = { 'field_2': { 'type': 'integer', 'dependencies': { 'field_1': {'maxlength': 1} …
El Ruso
  • 14,745
  • 4
  • 31
  • 54
0
votes
2 answers

Cerberus accept as valid the empty values

Trying to get this validation as acceptable True, where any of the fields could be empty: True (default i know), but when not empty than all the sequential conditionals must apply. SCHEMA v = Validator() schm = {'l_addrsch': {'type': 'string',…
Jorge Vidinha
  • 404
  • 7
  • 20
0
votes
1 answer

Cerberus: superfluous nesting in the error object

I use cerberus for validate my data, like: document = { "region": 77, "drivers": { "data": [ { "birthday": "2004-01-01", "kbm_class": "3", "driving_experience": 10 }, { "birthday": "1988-01-01", "kbm_class":…
0
votes
2 answers

How to add comments in a Cerberus schema?

I am using python-eve and i want to add some comments in the schema file (.json). So until now i have tried different comment styles: /*TYPE_OF_REFERENCE_MAPPING = { 'ABST': 'Abstract', 'ADVS': 'Audiovisual material', 'AGGR': 'Aggregated…
alemol
  • 8,058
  • 2
  • 24
  • 29
-1
votes
1 answer

Adding UUID type to Cerberus leads to BAD_TYPE error

I'm attempting to add custom data types to Cerberus. The UUID class works as expected (it's a standard library class) but I'm not able to validate with the UUID type using Cerberus. Secondarily I was not able to register multiple types in an an…
AlexLordThorsen
  • 8,057
  • 5
  • 48
  • 103
-1
votes
1 answer

Dictionary validation Cerberus use reserved keyword

I have a python dictionary I am trying to validate using cerberus. However, one of the fields in my dict is called "type" which conflicts with the keyword "type" reserved by the cerberus parser. Is there any way to get around this without having to…
asdf
  • 2,927
  • 2
  • 21
  • 42
1 2 3
8
9