cerberus validator to accept either smaller case or Title case

30 Views Asked by At

Looking for Cerberus validator to accept either 'x-api-key' or 'X-Api-Key' (title cased).

>>>>python3
Python 3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23) 
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cerberus
>>> v = cerberus.Validator(allow_unknown=True)
>>> v.validate({'x-api-key': "something"}, {'x-api-key': {'type': 'string', 'required': True, 'empty': False}})
True
>>> v.validate({'X-Api-Key': "something"}, {'x-api-key': {'type': 'string', 'required': True, 'empty': False}})
False

Is there a way to have a validation done to return True in both use case 'x-api-key' and/or 'X-Api-Key'

0

There are 0 best solutions below