Rules
All built-in Validation rules are registered automatically and referenced by name in the Rule Language. To include only the ones you use, see Code-Splitting. Each rule has its own page with usage examples, parameters, behavior, and error messages.
Presence
Presence rules decide whether a value must exist at all — the gate the other rules run behind.
| Rule | Parameters | Description |
|---|---|---|
required | — | Element must have a non-empty value. |
accepted | — | Value must be 'yes', 'on', '1', 1, true, or 'true'. |
filled | — | If present, value must not be empty. |
nullable | — | Allows the value to be empty — skips all other rules when it is. |
String Format
Format rules validate that a string follows a well-known shape.
| Rule | Parameters | Description |
|---|---|---|
email | — | Must be a valid email address. |
url | — | Must be a valid URL (http/https/ftp). |
ip | — | Must be a valid IPv4 or IPv6 address. |
ipv4 | — | Must be a valid IPv4 address. |
ipv6 | — | Must be a valid IPv6 address. |
alpha | — | May only contain Unicode letters. |
alpha_num | — | May only contain Unicode letters and digits. |
alpha_dash | — | May only contain Unicode letters, digits, dashes, and underscores. |
uuid | — | Must be a valid UUID. |
json | — | Must be a valid JSON string. |
timezone | — | Must be a valid IANA timezone (e.g. America/New_York). |
Type
Type rules validate the value's data type.
| Rule | Parameters | Description |
|---|---|---|
string | — | Must be a string. |
numeric | — | Must be a numeric value. |
integer | — | Must be an integer. |
boolean | — | Must be boolean-like (true, false, 0, 1, '0', '1'). |
array | — | Must be an array. |
date | — | Must be a valid date (requires the Date Module). |
Size
Size rules behave differently depending on the element type:
- String: size is the character count
- Numeric: size is the numeric value itself
- Array: size is the number of items
- File: size is in kilobytes
| Rule | Parameters | Description |
|---|---|---|
min | min | Size must be at least min. |
max | max | Size must not exceed max. |
between | min,max | Size must be between min and max (inclusive). |
size | size | Size must be exactly size. |
digits | digits | Must be numeric and have exactly digits digits. |
digits_between | min,max | Must be numeric with digit count between min and max. |
Comparison
These rules compare the element's size against another element's size. The other element is referenced by its path — see Referencing Other Elements.
| Rule | Parameters | Description |
|---|---|---|
gt | other | Size must be greater than other element's size. |
gte | other | Size must be greater than or equal to other element's size. |
lt | other | Size must be less than other element's size. |
lte | other | Size must be less than or equal to other element's size. |
Cross-field
Cross-field rules validate a value against another element's value.
| Rule | Parameters | Description |
|---|---|---|
same | other | Must have the same value as the other element. |
different | other | Must have a different value from the other element. |
confirmed | — | Expects a sibling element named {name}_confirmed with a matching value. |
in_array | other | Value must exist in the other element's array value. |
Membership
Membership rules check the value against a fixed list of allowed or forbidden values.
| Rule | Parameters | Description |
|---|---|---|
in | value1,value2,... | Value must be one of the listed values. |
not_in | value1,value2,... | Value must not be any of the listed values. |
Pattern
Pattern rules match the value against a regular expression.
| Rule | Parameters | Description |
|---|---|---|
regex | /pattern/flags | Value must match the regular expression. |
not_regex | /pattern/flags | Value must not match the regular expression. |
Date
Date rules require the Date Module to be installed. The date parameter can be a date string, the keywords today, tomorrow, yesterday, or another element's path.
| Rule | Parameters | Description |
|---|---|---|
date_format | format | Must match the given date format. |
date_equals | date | Must equal the given date. |
after | date | Must be after the given date or element. |
after_or_equal | date | Must be after or equal to the given date or element. |
before | date | Must be before the given date or element. |
before_or_equal | date | Must be before or equal to the given date or element. |
File
File rules validate uploaded files — their type, extension, and image dimensions.
| Rule | Parameters | Description |
|---|---|---|
file | — | Must be a file. |
image | — | Must be an image (jpg, jpeg, png, gif, bmp, svg, webp). |
mimes | ext1,ext2,... | File extension must be one of the listed types. |
mimetypes | type1,type2,... | File MIME type must be one of the listed types. |
dimensions | named params | Image dimensions must match the constraints (see below). |
The dimensions rule uses named parameters: width, height, min_width, min_height, max_width, max_height, and ratio.
Array
Array rules validate the items of array values.
| Rule | Parameters | Description |
|---|---|---|
distinct | — | All items in the array must be unique. |
Other
Rules tied to specific elements rather than general values.
| Rule | Parameters | Description |
|---|---|---|
captcha | — | Captcha must be verified (async — provided by captcha elements). |