Skip to content

in & not in

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

in:foo,bar,...

  • The field under validation must be included in the given list of values.

not_in:foo,bar,...

  • The field under validation must not be included in the given list of values.

data = {
   "north_america": "usa",
    "europe": "italy",
    "grade": "a",
}

rules = {
  "north_america": ["required", "in:usa,canada"],
  "europe": ["required", "not_in:china,japan"],
  "grade": ["required", "in:a,b"],
}

validate = PyValidations.make(data, rules)
Clone this wiki locally