Skip to content

Nullable

Majid Ahmaditabar edited this page Dec 10, 2021 · 3 revisions

nullable

  • The field under validation may be null.

data = {
  "name": "",
  "number": "a2",
}
rules = {
  "name": ["nullable", "alpha"],
  "number": ["nullable", "numeric"],
}

validate = PyValidations.make(data, rules)

name passed because is empty but number return error because not null and wrong number.

{
  "failed": True,
  "errors": {
    'number': ['The number must be a number.']
  }
}
Clone this wiki locally