-
Notifications
You must be signed in to change notification settings - Fork 240
Open
Description
How to create a dependency between two fields where the second field is mandatory only if the first field contains a specific value ?
Why don't I get a validation error when the second field is missing ?
In this example, I get True when I was expecting False:
>>> import sys
>>> print(sys.version_info)
sys.version_info(major=3, minor=9, micro=2, releaselevel='final', serial=0)
>>> import cerberus
>>> cerberus.__version__
'1.3.7'
>>> v = cerberus.Validator()
>>> schema = {'field1': {'type': 'string', 'allowed': ['text', 'choice']},
... 'field2': {'dependencies': {'field1': 'choice'}, 'type': 'number'}
... }
>>> document = {'field1': 'choice', 'field2': 1}
>>> v.validate(document, schema)
True
>>> del(document['field2'])
>>> v.validate(document, schema)
True
How do you create dependency between these two fields ?
Thank you for your help.
Regards.
Metadata
Metadata
Assignees
Labels
No labels