Syntax
Presence Rules
Control when fields are required.required
Field must be present and not empty.nullable
Field can be null. If present and not null, other rules apply.present
Field must exist in input (can be empty/null).sometimes
Only validate if field exists.Conditional Required
Make fields conditionally required.required_if
Required when another field equals a value.required_unless
Required unless another field equals a value.required_with
Required when another field is present.required_without
Required when another field is absent.required_with_all
Required when all specified fields are present.required_without_all
Required when all specified fields are absent.Type Rules
Validate data types.string
Must be a string.integer
Must be an integer (no decimals).numeric
Must be a number (integer or float).boolean
Must betrue or false.
array
Must be an array.object
Must be an object.Size Rules
Validate size, length, or value. Size rules behave differently based on the field type:- Strings: Validates character length
- Numbers: Validates the numeric value
- Arrays: Validates item count
min
Minimum size/length/value.max
Maximum size/length/value.size
Exact size/length/value.between
Value/length must be in range.Format Rules
Validate string formats.url
Valid URL format.uuid
Valid UUID format.ip
Valid IP address (v4 or v6).ipv4
Valid IPv4 address.ipv6
Valid IPv6 address.json
Valid JSON string.regex
Matches regular expression pattern.Date Rules
Validate date values.date
Valid date format.datetime
Valid datetime format.before
Date must be before specified date.after
Date must be after specified date.before_or_equal
Date must be before or equal to specified date.after_or_equal
Date must be after or equal to specified date.Comparison Rules
Compare fields to each other.same
Must match another field’s value.different
Must differ from another field’s value.confirmed
Field must have a matching_confirmation field.
email_confirmation field with the same value.
gt
Greater than another field.gte
Greater than or equal to another field.lt
Less than another field.lte
Less than or equal to another field.Inclusion Rules
Validate against a list of values.in
Must be one of the specified values.not_in
Must not be one of the specified values.Control Rules
Control validation behavior.bail
Stop validating the field on first error.bail, all rules are checked. With bail, validation stops at first failure.
Array Validation
Validate nested array items using.* wildcard.
Basic Array Items
Object Array Items
Nested Array Validation
Complete Examples
User Registration
Product Creation
Order Placement
Profile Update
Error Messages
Each rule generates a specific error message:| Rule | Message Example |
|---|---|
| required | The name field is required |
| The email field must be a valid email address | |
| min (string) | The password field must be at least 8 characters |
| min (number) | The age field must be at least 18 |
| min (array) | The items field must have at least 1 items |
| max | The title field may not be greater than 100 characters |
| in | The status field must be one of: pending, active, closed |
| uuid | The id field must be a valid UUID |
| same | The password_confirmation field must match password |
Related
- Request Node - Validation node usage
- Condition Node - Branch on validation results
- Abort Node - Error responses