You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

File

Implements

Uses

Properties

protected

$allowedMimetypes array

The MIME types that the given file should match. This array may also contain file extensions.

Default: []
protected

$minimumFileSize null|int

The minimum size in kilobytes that the file can be.

Default: null
protected

$maximumFileSize null|int

The maximum size in kilobytes that the file can be.

Default: null
protected

$customRules array

An array of custom rules that will be merged into the validation rules.

Default: []
protected

$messages array

The error message after validation, if any.

Default: []
protected

$data array

The data under validation.

Default: null
protected

$validator Validator

The validator performing the validation.

Default: null
public static

$defaultCallback string|array|callable|null

The callback that will generate the "default" version of the file rule.

Default: null

Methods

public static

defaults ( $callback ) : static|null

Set the default callback to be used for determining the file default rules.

Parameters

  • $callback static|callable|null
public static

default ( ) : static

Get the default configuration of the file rule.

public static

image ( ) : ImageFile

Limit the uploaded file to only image types.

public static

types ( $mimetypes ) : static

Limit the uploaded file to the given MIME types or file extensions.

Parameters

  • $mimetypes string|array
public

size ( $size ) : $this

Indicate that the uploaded file should be exactly a certain size in kilobytes.

Parameters

  • $size string|int
public

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
public

min ( $size ) : $this

Indicate that the uploaded file should be no less than the given number of kilobytes.

Parameters

  • $size string|int
public

max ( $size ) : $this

Indicate that the uploaded file should be no more than the given number of kilobytes.

Parameters

  • $size string|int
protected

toKilobytes ( $size ) : mixed

Convert a potentially human-friendly file size to kilobytes.

Parameters

  • $size string|int
public

rules ( $rules ) : $this

Specify additional validation rules that should be merged with the default rules during validation.

Parameters

  • $rules string|array
public

passes ( $attribute , $value ) : bool

Determine if the validation rule passes.

Parameters

  • $attribute string
  • $value mixed
protected

buildValidationRules ( ) : array

Build the array of underlying validation rules based on the current state.

protected

buildMimetypes ( ) : array

Separate the given mimetypes from extensions and return an array of correct rules to validate against.

protected

fail ( $messages ) : bool

Adds the given failures, and return false.

Parameters

  • $messages array|string
public

message ( ) : array

Get the validation error message.

public

setValidator ( $validator ) : $this

Set the current validator.

Parameters

public

setData ( $data ) : $this

Set the current data under validation.

Parameters

  • $data array