class File implements Rule, DataAwareRule, ValidatorAwareRule (View source)
| Conditionable | |
| Macroable |
| static protected array | $macros | The registered string macros. | from Macroable |
| protected array | $allowedMimetypes | The MIME types that the given file should match. This array may also contain file extensions. | |
| protected array | $allowedExtensions | The extensions that the given file should match. | |
| protected null|int | $minimumFileSize | The minimum size in kilobytes that the file can be. | |
| protected null|int | $maximumFileSize | The maximum size in kilobytes that the file can be. | |
| protected array | $customRules | An array of custom rules that will be merged into the validation rules. | |
| protected array | $messages | The error message after validation, if any. | |
| protected array | $data | The data under validation. | |
| protected Validator | $validator | The validator performing the validation. | |
| static string|array|callable|null | $defaultCallback | The callback that will generate the "default" version of the file rule. |
| $this|TWhenReturnType | when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy. | from Conditionable |
| $this|TUnlessReturnType | unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy. | from Conditionable |
| static void | macro(string $name, object|callable $macro)
Register a custom macro. | from Macroable |
| static void | mixin(object $mixin, bool $replace = true)
Mix another object into the class. | from Macroable |
| static bool | hasMacro(string $name)
Checks if macro is registered. | from Macroable |
| static void | flushMacros()
Flush the existing macros. | from Macroable |
| static mixed | __callStatic(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| mixed | __call(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| static File|null | defaults(File|callable|null $callback = null)
Set the default callback to be used for determining the file default rules. | |
| static File | default()
Get the default configuration of the file rule. | |
| static ImageFile | image()
Limit the uploaded file to only image types. | |
| static File | types(string|array<int,string> $mimetypes)
Limit the uploaded file to the given MIME types or file extensions. | |
| $this | extensions(string|array<int,string> $extensions)
Limit the uploaded file to the given file extensions. | |
| $this | size(string|int $size)
Indicate that the uploaded file should be exactly a certain size in kilobytes. | |
| $this | between(string|int $minSize, string|int $maxSize)
Indicate that the uploaded file should be between a minimum and maximum size in kilobytes. | |
| $this | min(string|int $size)
Indicate that the uploaded file should be no less than the given number of kilobytes. | |
| $this | max(string|int $size)
Indicate that the uploaded file should be no more than the given number of kilobytes. | |
| mixed | toKilobytes(string|int $size)
Convert a potentially human-friendly file size to kilobytes. | |
| $this | rules(string|array $rules)
Specify additional validation rules that should be merged with the default rules during validation. | |
| bool | passes(string $attribute, mixed $value)
Determine if the validation rule passes. | |
| array | buildValidationRules()
Build the array of underlying validation rules based on the current state. | |
| array | buildMimetypes()
Separate the given mimetypes from extensions and return an array of correct rules to validate against. | |
| bool | fail(array|string $messages)
Adds the given failures, and return false. | |
| string|array | message()
Get the validation error message. | |
| $this | setValidator(Validator $validator)
Set the current validator. | |
| $this | setData(array $data)
Set the current data under validation. |
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Register a custom macro.
Mix another object into the class.
Checks if macro is registered.
Flush the existing macros.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Set the default callback to be used for determining the file default rules.
If no arguments are passed, the default file rule configuration will be returned.
Get the default configuration of the file rule.
Limit the uploaded file to only image types.
Limit the uploaded file to the given MIME types or file extensions.
Limit the uploaded file to the given file extensions.
Indicate that the uploaded file should be exactly a certain size in kilobytes.
Indicate that the uploaded file should be between a minimum and maximum size in kilobytes.
Indicate that the uploaded file should be no less than the given number of kilobytes.
Indicate that the uploaded file should be no more than the given number of kilobytes.
Convert a potentially human-friendly file size to kilobytes.
Specify additional validation rules that should be merged with the default rules during validation.
Determine if the validation rule passes.
Build the array of underlying validation rules based on the current state.
Separate the given mimetypes from extensions and return an array of correct rules to validate against.
Adds the given failures, and return false.
Get the validation error message.
Set the current validator.
Set the current data under validation.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Validation/Rules/File.html