Can also be passed as an array
$validatedData = $request->validate([
'title' => ['required', 'unique:posts', 'max:255'],
'body' => ['required'],
]);
#after:date
Field must be a value after a given date.
'start\_date' => 'required|date|after:tomorrow'
Instead of a date string, you may specify another field to compare against the date
'finish\_date' => 'required|date|after:start\_date'
See before:date
#after_or_equal:date
Field must be a value after or equal to the given date.
See after:date
#before:date
Field must be a value preceding the given date.
The name of another field may be supplied as the value of date
.
See after:date
#alpha_num
Field must be entirely alpha-numeric characters
#boolean
Field must be able to be cast as a boolean
.
Accepted input are true
, false
, 1
, 0
, "1"
, and "0"
#confirmed
Field must have a matching field of {field}_confirmation
.
For example, if the field is password, a matching password_confirmation
field must be present
#current_password
Field must match the authenticated user's password.
#date
Field must be a valid, non-relative date according to the strtotime
PHP function.
#email
Field must be formatted as an email address.
#file
Field must be a successfully uploaded file.
See: Uploaded Files
#max:value
Field must be less than or equal to a maximum value.
Strings, numerics, arrays, and files are evaluated like the size rule.
#min:value
Field must have a minimum value.
Strings, numerics, arrays, and files are evaluated like the size rule.
#mimetypes:text/plain,…
File must match one of the given MIME types:
'video' => 'mimetypes:video/avi,video/mpeg,video/quicktime'
File's contents will be read and the framework will attempt to guess the
MIME type, regardless of the client's provided MIME type.
#mimes:foo,bar,…
Field must have a MIME type corresponding to one of the listed extensions.
'photo' => 'mimes:jpg,bmp,png'
File's contents will be read and the framework will attempt to guess the
MIME type, regardless of the client's provided MIME type.
Full listing of MIME types & extensions
#nullable
Field may be null.
#numeric
Field must be numeric.
#password
Field must match the authenticated user's password.
#prohibited
Field must be empty or not present.
#prohibited_if:anotherfield,value,…
Field must be empty or not present if the
anotherfield field is equal to any value.
#prohibited_unless:anotherfield,value,…
Field must be empty or not present unless the
anotherfield field is equal to any value.
#required
Field must be present in the input data and not empty.
A field is considered "empty" if one of the following conditions are true:
- The value is
null
.
- The value is an empty string.
- The value is an empty array or empty
Countable
object.
- The value is an uploaded file with no path.
#required_with:foo,bar,…
Field must be present and not empty, only if any of the other
specified fields are present and not empty
#size:value
Field must have a size matching the given value.
- For strings: number of characters
- For numeric data: integer value (must also have the
numeric
or integer
rule).
- For arrays: count of the array
- For files: file size in kilobytes
// Validate that a string is exactly 12 characters long...
'title' => 'size:12';
// Validate that a provided integer equals 10...
'seats' => 'integer|size:10';
// Validate that an array has exactly 5 elements...
'tags' => 'array|size:5';
// Validate that an uploaded file is exactly 512 kilobytes...
'image' => 'file|size:512';
#unique:table,column
Field must not exist within the given database table
#url
Field must be a valid URL
See all available rules