Skip to content

Alpha and String

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

string

  • The field under validation must be a string. If you would like to allow the field to also be null, you should assign the nullable rule to the field.

alpha

  • The field under validation must be entirely alphabetic characters.

start_with:foo

  • The field under validation must start with the given values.

end_with:foo

  • The field under validation must end with the given values

data = {
     "name": "John Doe",
     "user_name": "John_007",
     "start_code": "G123other_string",
     "end_code": "other_stringG123"
}

rules = {
     "name": ["required", "alpha"],
     "user_name": ["required", "string"],
     "start_code": ["required", "start_with:G123"],
     "end_code": ["required", "end_with:G123"],
}

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