Built-in validation rules
Required validators
required
: value should not benull
, an empty string or an empty arrayrequired_with
: value is required when another item is present in the context. Rule params:target
required_without
: value is required when another item is not present in the context. Rule params:target
String validators
alpha
: values must contain only letters and spacesalpha_num
: values must contain letters, numbers and spacesslug
: values must contain letters, numbers, dashes, underscores and spacesmin_length
: string's length should be greater than a specified value. Rule params:min
max_length
: string's length should be shorter than a specified value. Rule params:max
contains
: string's length should be shorter than a specified value. Rule params:max
starts_with
: string's length should be shorter than a specified value. Rule params:max
ends_with
: string's length should be shorter than a specified value. Rule params:max
Array validators
array_min_length
: array must contain at least a specific number of items: Rule params:min
array_max_length
: array must contain at most a specific number of items: Rule params:max
Number validators
number
: value must be a valid numberinteger
: value must be a valid integermin
: value must be less than a number. Rule params:max
max
: value must be greater than a number. Rule params:min
Email/URLs validators
email
: value must be an email address. Uses a regular expression for validationurl
: value must be a valid URL address (http, https, ftp etc)
Other validators
regex
: value must match a regular expression pattern. Rule params:pattern
equal
: the value must be the same as predefined value. Rule params:target
in_list
: the value must be in a list of acceptable values. Rule params:list
not_in_list
: the value must not be in a list of forbidden values: Rule params:list