0

I'm new to Cerberus recently upgraded the Cerberus version to 1.3.2 from 1.1. But getting validation errors. Please find the validation schema.

my_schema = 
{
    'email': {
        'type': 'string', 'maxlength': 1000,
        'regex': EMAIL_PATTERN, 'required': True
    },
    'guest': {
        'type': 'boolean', 'required': False,
        'excludes': ['password', 'issue_password_reset']
    },
    'password': {
        'type': 'string', 'minlength': 9, 'required': True,
        'excludes': 'issue_password_reset'
    },
    'prefix': {
        'type': 'string', 'nullable': True,
        'required': False, 'maxlength': 10
    },
    'first_name': {
        'type': 'string', 'nullable': True,
        'required': False, 'maxlength': 50
    },
    'last_name': {
        'type': 'string', 'nullable': True,
        'required': False, 'maxlength': 50
    },
    'phone_number': {
        'type': 'string', 'required': False,
        'nullable': True, 'regex': PHONE_NUMBER_PATTERN
    },
    'birthday': {
        'type': 'string', 'required': True,
        'excludes': 'is_legal_drinking_age'
    },
    'is_legal_drinking_age': {
        'type': 'boolean', 'required': True,
        'excludes': 'birthday'
    },
    'issue_password_reset': {
        'type': 'boolean', 'required': True,
        'excludes': 'password'
    },
}

data = {
        "email": "guest123@email.com",
        "guest": True,
        "birthday": "1975-05-05",
        "prefix": "Ms.",
        "first_name": "Allison",
        "last_name": "Smith",
        "phone_number": "(212) 555-2002"
    }

valid = Validator(default_schema)
resp = valid.validate(data)
print(valid.errors)
print(resp)

For Cerberus version 1.3.2, getting error

For Cerberus version 1.3.2, getting error

For Cerberus version 1.1, validation is working properly.

enter image description here

Hoping to find some help.

funky-future
  • 3,716
  • 1
  • 30
  • 43
reegan vijay
  • 161
  • 11

1 Answers1

0

As noted here, the behaviour is correct as the document doesn't contain fields that are defined as required. The returned errors point that out.

funky-future
  • 3,716
  • 1
  • 30
  • 43