File
Implements
Uses
Properties
$allowedMimetypes array
The MIME types that the given file should match. This array may also contain file extensions.
$minimumFileSize null|int
The minimum size in kilobytes that the file can be.
$maximumFileSize null|int
The maximum size in kilobytes that the file can be.
$customRules array
An array of custom rules that will be merged into the validation rules.
$messages array
The error message after validation, if any.
$data array
The data under validation.
$defaultCallback string|array|callable|null
The callback that will generate the "default" version of the file rule.
Methods
defaults ( $callback ) : static|null
Set the default callback to be used for determining the file default rules.
Parameters
- $callback static|callable|null
default ( ) : static
Get the default configuration of the file rule.
image ( ) : ImageFile
Limit the uploaded file to only image types.
types ( $mimetypes ) : static
Limit the uploaded file to the given MIME types or file extensions.
Parameters
-
$mimetypes
string|array
size ( $size ) : $this
Indicate that the uploaded file should be exactly a certain size in kilobytes.
Parameters
- $size string|int
between ( $minSize , $maxSize ) : $this
Indicate that the uploaded file should be between a minimum and maximum size in kilobytes.
Parameters
- $minSize string|int
- $maxSize string|int
min ( $size ) : $this
Indicate that the uploaded file should be no less than the given number of kilobytes.
Parameters
- $size string|int
max ( $size ) : $this
Indicate that the uploaded file should be no more than the given number of kilobytes.
Parameters
- $size string|int
toKilobytes ( $size ) : mixed
Convert a potentially human-friendly file size to kilobytes.
Parameters
- $size string|int
rules ( $rules ) : $this
Specify additional validation rules that should be merged with the default rules during validation.
Parameters
- $rules string|array
passes ( $attribute , $value ) : bool
Determine if the validation rule passes.
Parameters
- $attribute string
- $value mixed
buildValidationRules ( ) : array
Build the array of underlying validation rules based on the current state.
buildMimetypes ( ) : array
Separate the given mimetypes from extensions and return an array of correct rules to validate against.
fail ( $messages ) : bool
Adds the given failures, and return false.
Parameters
- $messages array|string
message ( ) : array
Get the validation error message.
setValidator ( $validator ) : $this
Set the current validator.
Parameters
- $validator Validator
setData ( $data ) : $this
Set the current data under validation.
Parameters
- $data array