Documentation

Validator
in package
implements Validator Uses FormatsMessages, ValidatesAttributes

Interfaces, Classes and Traits

Validator

Table of Contents

$customAttributes  : array<string|int, mixed>
The array of custom attribute names.
$customMessages  : array<string|int, mixed>
The array of custom error messages.
$customValues  : array<string|int, mixed>
The array of custom displayable values.
$extensions  : array<string|int, mixed>
All of the custom validator extensions.
$fallbackMessages  : array<string|int, mixed>
The array of fallback error messages.
$replacers  : array<string|int, mixed>
All of the custom replacer extensions.
$after  : array<string|int, mixed>
All of the registered "after" callbacks.
$container  : Container
The container instance.
$currentRule  : string
The current rule that is validating.
$data  : array<string|int, mixed>
The data under validation.
$dependentRules  : array<string|int, mixed>
The validation rules which depend on other fields as parameters.
$failedRules  : array<string|int, mixed>
The failed validation rules.
$fileRules  : array<string|int, mixed>
The validation rules that may be applied to files.
$implicitAttributes  : array<string|int, mixed>
The array of wildcard attributes with their asterisks expanded.
$implicitRules  : array<string|int, mixed>
The validation rules that imply the field is required.
$initialRules  : array<string|int, mixed>
The initial rules provided.
$messages  : MessageBag
The message bag instance.
$numericRules  : array<string|int, mixed>
The numeric related validation rules.
$presenceVerifier  : PresenceVerifierInterface
The Presence Verifier implementation.
$rules  : array<string|int, mixed>
The rules to be applied to the data.
$sizeRules  : array<string|int, mixed>
The size related validation rules.
$translator  : Translator
The Translator implementation.
__call()  : mixed
Handle dynamic calls to class methods.
__construct()  : void
Create a new Validator instance.
addCustomAttributes()  : $this
Add custom attributes to the validator.
addCustomValues()  : $this
Add the custom values for the validator.
addDependentExtension()  : void
Register a custom dependent validator extension.
addDependentExtensions()  : void
Register an array of custom implicit validator extensions.
addExtension()  : void
Register a custom validator extension.
addExtensions()  : void
Register an array of custom validator extensions.
addImplicitExtension()  : void
Register a custom implicit validator extension.
addImplicitExtensions()  : void
Register an array of custom implicit validator extensions.
addReplacer()  : void
Register a custom validator message replacer.
addReplacers()  : void
Register an array of custom validator message replacers.
addRules()  : void
Parse the given rules and merge them into current rules.
after()  : $this
Add an after validation callback.
attributes()  : array<string|int, mixed>
Get the data under validation.
errors()  : MessageBag
An alternative more semantic shortcut to the message container.
failed()  : array<string|int, mixed>
Get the failed validation rules.
fails()  : bool
Determine if the data fails the validation rules.
getData()  : array<string|int, mixed>
Get the data under validation.
getDisplayableAttribute()  : string
Get the displayable name of the attribute.
getDisplayableValue()  : string
Get the displayable name of the value.
getMessageBag()  : MessageBag
Get the messages for the instance.
getPresenceVerifier()  : PresenceVerifierInterface
Get the Presence Verifier implementation.
getRules()  : array<string|int, mixed>
Get the validation rules.
getTranslator()  : Translator
Get the Translator implementation.
guessColumnForQuery()  : string
Guess the database column from the given attribute name.
hasRule()  : bool
Determine if the given attribute has a rule in the given set.
invalid()  : array<string|int, mixed>
Returns the data which was invalid.
isValidFileInstance()  : bool
Check that the given value is a valid file instance.
makeReplacements()  : string
Replace all error message place-holders with actual values.
messages()  : MessageBag
Get the message container for the validator.
parseData()  : array<string|int, mixed>
Parse the data array, converting dots to ->.
passes()  : bool
Determine if the data passes the validation rules.
setAttributeNames()  : $this
Set the custom attributes on the validator.
setContainer()  : void
Set the IoC container instance.
setCustomMessages()  : $this
Set the custom messages for the validator.
setData()  : $this
Set the data under validation.
setFallbackMessages()  : void
Set the fallback messages for the validator.
setPresenceVerifier()  : void
Set the Presence Verifier implementation.
setRules()  : $this
Set the validation rules.
setTranslator()  : void
Set the Translator implementation.
setValueNames()  : $this
Set the custom values on the validator.
sometimes()  : $this
Add conditions to a given field based on a Closure.
valid()  : array<string|int, mixed>
Returns the data which was valid.
validate()  : void
Run the validator's rules against its data.
validateAccepted()  : bool
Validate that an attribute was "accepted".
validateActiveUrl()  : bool
Validate that an attribute is an active URL.
validateAfter()  : bool
Validate the date is after a given date.
validateAfterOrEqual()  : bool
Validate the date is equal or after a given date.
validateAlpha()  : bool
Validate that an attribute contains only alphabetic characters.
validateAlphaDash()  : bool
Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
validateAlphaNum()  : bool
Validate that an attribute contains only alpha-numeric characters.
validateArray()  : bool
Validate that an attribute is an array.
validateBail()  : bool
"Break" on first validation fail.
validateBefore()  : bool
Validate the date is before a given date.
validateBeforeOrEqual()  : bool
Validate the date is before or equal a given date.
validateBetween()  : bool
Validate the size of an attribute is between a set of values.
validateBoolean()  : bool
Validate that an attribute is a boolean.
validateConfirmed()  : bool
Validate that an attribute has a matching confirmation.
validateDate()  : bool
Validate that an attribute is a valid date.
validateDateEquals()  : bool
Validate that an attribute is equal to another date.
validateDateFormat()  : bool
Validate that an attribute matches a date format.
validateDifferent()  : bool
Validate that an attribute is different from another attribute.
validateDigits()  : bool
Validate that an attribute has a given number of digits.
validateDigitsBetween()  : bool
Validate that an attribute is between a given number of digits.
validateDimensions()  : bool
Validate the dimensions of an image matches the given values.
validateDistinct()  : bool
Validate an attribute is unique among other values.
validateEmail()  : bool
Validate that an attribute is a valid e-mail address.
validateExists()  : bool
Validate the existence of an attribute value in a database table.
validateFile()  : bool
Validate the given value is a valid file.
validateFilled()  : bool
Validate the given attribute is filled if it is present.
validateImage()  : bool
Validate the MIME type of a file is an image MIME type.
validateIn()  : bool
Validate an attribute is contained within a list of values.
validateInArray()  : bool
Validate that the values of an attribute is in another attribute.
validateInteger()  : bool
Validate that an attribute is an integer.
validateIp()  : bool
Validate that an attribute is a valid IP.
validateIpv4()  : bool
Validate that an attribute is a valid IPv4.
validateIpv6()  : bool
Validate that an attribute is a valid IPv6.
validateJson()  : bool
Validate the attribute is a valid JSON string.
validateMax()  : bool
Validate the size of an attribute is less than a maximum value.
validateMimes()  : bool
Validate the guessed extension of a file upload is in a set of file extensions.
validateMimetypes()  : bool
Validate the MIME type of a file upload attribute is in a set of MIME types.
validateMin()  : bool
Validate the size of an attribute is greater than a minimum value.
validateNotIn()  : bool
Validate an attribute is not contained within a list of values.
validateNullable()  : bool
"Indicate" validation should pass if value is null.
validateNumeric()  : bool
Validate that an attribute is numeric.
validatePresent()  : bool
Validate that an attribute exists even if not filled.
validateRegex()  : bool
Validate that an attribute passes a regular expression check.
validateRequired()  : bool
Validate that a required attribute exists.
validateRequiredIf()  : bool
Validate that an attribute exists when another attribute has a given value.
validateRequiredUnless()  : bool
Validate that an attribute exists when another attribute does not have a given value.
validateRequiredWith()  : bool
Validate that an attribute exists when any other attribute exists.
validateRequiredWithAll()  : bool
Validate that an attribute exists when all other attributes exists.
validateRequiredWithout()  : bool
Validate that an attribute exists when another attribute does not.
validateRequiredWithoutAll()  : bool
Validate that an attribute exists when all other attributes do not.
validateSame()  : bool
Validate that two attributes match.
validateSize()  : bool
Validate the size of an attribute.
validateSometimes()  : bool
"Validate" optional attributes.
validateString()  : bool
Validate that an attribute is a string.
validateTimezone()  : bool
Validate that an attribute is a valid timezone.
validateUnique()  : bool
Validate the uniqueness of an attribute value on a given database table.
validateUrl()  : bool
Validate that an attribute is a valid URL.
addFailure()  : void
Add a failed rule and error message to the collection.
allFailingRequired()  : bool
Determine if all of the given attributes fail the required test.
anyFailingRequired()  : bool
Determine if any of the given attributes fail the required test.
attributesThatHaveMessages()  : array<string|int, mixed>
Generate an array of all attributes that have messages.
callClassBasedExtension()  : bool
Call a class based validator extension.
callClassBasedReplacer()  : string
Call a class based validator message replacer.
callExtension()  : bool|null
Call a custom validator extension.
callReplacer()  : string|null
Call a custom validator message replacer.
checkDateTimeOrder()  : bool
Given two date/time strings, check that one is after the other.
compare()  : bool
Determine if a comparison passes between the given values.
compareDates()  : bool
Compare a given date against another using an operator.
convertValuesToBoolean()  : array<string|int, mixed>
Convert the given values to boolean if they are string "true" / "false".
dependsOnOtherFields()  : bool
Determine if the given rule depends on other fields.
failsBasicDimensionChecks()  : bool
Test if the given width and height fail any conditions.
failsRatioCheck()  : bool
Determine if the given parameters fail a dimension ratio check.
getAttributeFromTranslations()  : string
Get the given attribute from the attribute translations.
getAttributeList()  : array<string|int, mixed>
Transform an array of attributes to their displayable form.
getAttributeType()  : string
Get the data type of the given attribute.
getCustomMessageFromTranslator()  : string
Get the custom error message from translator.
getDateFormat()  : string|null
Get the date format for an attribute if it has one.
getDateTimestamp()  : int
Get the date timestamp.
getDateTimeWithOptionalFormat()  : DateTime|null
Get a DateTime instance from a string.
getExistCount()  : int
Get the number of records that exist in storage.
getExplicitKeys()  : array<string|int, mixed>
Get the explicit keys from an attribute flattened with dot notation.
getExtraConditions()  : array<string|int, mixed>
Get the extra conditions for a unique / exists rule.
getFromLocalArray()  : string|null
Get the inline message for a rule if it exists.
getInlineMessage()  : string|null
Get the proper inline error message for standard and size rules.
getMessage()  : string
Get the validation message for an attribute and rule.
getPresenceVerifierFor()  : PresenceVerifierInterface
Get the Presence Verifier implementation.
getPrimaryAttribute()  : string
Get the primary attribute name.
getQueryColumn()  : bool
Get the column name for an exists / unique query.
getRule()  : array<string|int, mixed>|null
Get a rule and its parameters for a given attribute.
getSize()  : mixed
Get the size of an attribute.
getSizeMessage()  : string
Get the proper error message for an attribute and size rule.
getUniqueExtra()  : array<string|int, mixed>
Get the extra conditions for a unique rule.
getUniqueIds()  : array<string|int, mixed>
Get the excluded ID column and value for the unique rule.
getValue()  : mixed
Get the value of a given attribute.
getWildcardCustomMessages()  : string
Check the given messages for a wildcard key.
hasNotFailedPreviousRuleIfPresenceRule()  : bool
Determine if it's a necessary presence validation.
isImplicit()  : bool
Determine if a given rule implies the attribute is required.
isNotNullIfMarkedAsNullable()  : bool
Determine if the attribute fails the nullable check.
isValidatable()  : bool
Determine if the attribute is validatable.
parseNamedParameters()  : array<string|int, mixed>
Parse named parameters to $key => $value items.
parseTable()  : array<string|int, mixed>
Parse the connection / table for the unique / exists rules.
passesOptionalCheck()  : bool
Determine if the attribute passes any optional check.
prepareUniqueId()  : int
Prepare the given ID for querying.
presentOrRuleIsImplicit()  : bool
Determine if the field is present, or the rule implies required.
replaceAsterisksInParameters()  : array<string|int, mixed>
Replace each field parameter which has asterisks with the given keys.
replaceAttributePlaceholder()  : string
Replace the :attribute placeholder in the given message.
replaceInputPlaceholder()  : string
Replace the :input placeholder in the given message.
requireParameterCount()  : void
Require a certain number of parameters to be present.
shouldBlockPhpUpload()  : bool
Check if PHP uploads are explicitly allowed.
shouldStopValidating()  : bool
Check if we should stop further validations on a given attribute.
validateAttribute()  : void
Validate a given attribute against a rule.
validateUsingCustomRule()  : void
Validate an attribute using a custom rule object.

Properties

$customAttributes

The array of custom attribute names.

public array<string|int, mixed> $customAttributes = []

$customMessages

The array of custom error messages.

public array<string|int, mixed> $customMessages = []

$customValues

The array of custom displayable values.

public array<string|int, mixed> $customValues = []

$extensions

All of the custom validator extensions.

public array<string|int, mixed> $extensions = []

$fallbackMessages

The array of fallback error messages.

public array<string|int, mixed> $fallbackMessages = []

$replacers

All of the custom replacer extensions.

public array<string|int, mixed> $replacers = []

$after

All of the registered "after" callbacks.

protected array<string|int, mixed> $after = []

$currentRule

The current rule that is validating.

protected string $currentRule

$data

The data under validation.

protected array<string|int, mixed> $data

$dependentRules

The validation rules which depend on other fields as parameters.

protected array<string|int, mixed> $dependentRules = ['RequiredWith', 'RequiredWithAll', 'RequiredWithout', 'RequiredWithoutAll', 'RequiredIf', 'RequiredUnless', 'Confirmed', 'Same', 'Different', 'Unique', 'Before', 'After', 'BeforeOrEqual', 'AfterOrEqual']

$failedRules

The failed validation rules.

protected array<string|int, mixed> $failedRules = []

$fileRules

The validation rules that may be applied to files.

protected array<string|int, mixed> $fileRules = ['File', 'Image', 'Mimes', 'Mimetypes', 'Min', 'Max', 'Size', 'Between', 'Dimensions']

$implicitAttributes

The array of wildcard attributes with their asterisks expanded.

protected array<string|int, mixed> $implicitAttributes = []

$implicitRules

The validation rules that imply the field is required.

protected array<string|int, mixed> $implicitRules = ['Required', 'Filled', 'RequiredWith', 'RequiredWithAll', 'RequiredWithout', 'RequiredWithoutAll', 'RequiredIf', 'RequiredUnless', 'Accepted', 'Present']

$initialRules

The initial rules provided.

protected array<string|int, mixed> $initialRules

$numericRules

The numeric related validation rules.

protected array<string|int, mixed> $numericRules = ['Numeric', 'Integer']

$rules

The rules to be applied to the data.

protected array<string|int, mixed> $rules

$sizeRules

The size related validation rules.

protected array<string|int, mixed> $sizeRules = ['Size', 'Between', 'Min', 'Max']

Methods

__call()

Handle dynamic calls to class methods.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__construct()

Create a new Validator instance.

public __construct(Translator $translator, array<string|int, mixed> $data, array<string|int, mixed> $rules[, array<string|int, mixed> $messages = [] ][, array<string|int, mixed> $customAttributes = [] ]) : void
Parameters
$translator : Translator
$data : array<string|int, mixed>
$rules : array<string|int, mixed>
$messages : array<string|int, mixed> = []
$customAttributes : array<string|int, mixed> = []
Return values
void

addCustomAttributes()

Add custom attributes to the validator.

public addCustomAttributes(array<string|int, mixed> $customAttributes) : $this
Parameters
$customAttributes : array<string|int, mixed>
Return values
$this

addCustomValues()

Add the custom values for the validator.

public addCustomValues(array<string|int, mixed> $customValues) : $this
Parameters
$customValues : array<string|int, mixed>
Return values
$this

addDependentExtension()

Register a custom dependent validator extension.

public addDependentExtension(string $rule, Closure|string $extension) : void
Parameters
$rule : string
$extension : Closure|string
Return values
void

addDependentExtensions()

Register an array of custom implicit validator extensions.

public addDependentExtensions(array<string|int, mixed> $extensions) : void
Parameters
$extensions : array<string|int, mixed>
Return values
void

addExtension()

Register a custom validator extension.

public addExtension(string $rule, Closure|string $extension) : void
Parameters
$rule : string
$extension : Closure|string
Return values
void

addExtensions()

Register an array of custom validator extensions.

public addExtensions(array<string|int, mixed> $extensions) : void
Parameters
$extensions : array<string|int, mixed>
Return values
void

addImplicitExtension()

Register a custom implicit validator extension.

public addImplicitExtension(string $rule, Closure|string $extension) : void
Parameters
$rule : string
$extension : Closure|string
Return values
void

addImplicitExtensions()

Register an array of custom implicit validator extensions.

public addImplicitExtensions(array<string|int, mixed> $extensions) : void
Parameters
$extensions : array<string|int, mixed>
Return values
void

addReplacer()

Register a custom validator message replacer.

public addReplacer(string $rule, Closure|string $replacer) : void
Parameters
$rule : string
$replacer : Closure|string
Return values
void

addReplacers()

Register an array of custom validator message replacers.

public addReplacers(array<string|int, mixed> $replacers) : void
Parameters
$replacers : array<string|int, mixed>
Return values
void

addRules()

Parse the given rules and merge them into current rules.

public addRules(array<string|int, mixed> $rules) : void
Parameters
$rules : array<string|int, mixed>
Return values
void

after()

Add an after validation callback.

public after(callable|string $callback) : $this
Parameters
$callback : callable|string
Return values
$this

attributes()

Get the data under validation.

public attributes() : array<string|int, mixed>
Return values
array<string|int, mixed>

failed()

Get the failed validation rules.

public failed() : array<string|int, mixed>
Return values
array<string|int, mixed>

fails()

Determine if the data fails the validation rules.

public fails() : bool
Return values
bool

getData()

Get the data under validation.

public getData() : array<string|int, mixed>
Return values
array<string|int, mixed>

getDisplayableAttribute()

Get the displayable name of the attribute.

public getDisplayableAttribute(string $attribute) : string
Parameters
$attribute : string
Return values
string

getDisplayableValue()

Get the displayable name of the value.

public getDisplayableValue(string $attribute, mixed $value) : string
Parameters
$attribute : string
$value : mixed
Return values
string

getRules()

Get the validation rules.

public getRules() : array<string|int, mixed>
Return values
array<string|int, mixed>

guessColumnForQuery()

Guess the database column from the given attribute name.

public guessColumnForQuery(string $attribute) : string
Parameters
$attribute : string
Return values
string

hasRule()

Determine if the given attribute has a rule in the given set.

public hasRule(string $attribute, string|array<string|int, mixed> $rules) : bool
Parameters
$attribute : string
$rules : string|array<string|int, mixed>
Return values
bool

invalid()

Returns the data which was invalid.

public invalid() : array<string|int, mixed>
Return values
array<string|int, mixed>

isValidFileInstance()

Check that the given value is a valid file instance.

public isValidFileInstance(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

makeReplacements()

Replace all error message place-holders with actual values.

public makeReplacements(string $message, string $attribute, string $rule, array<string|int, mixed> $parameters) : string
Parameters
$message : string
$attribute : string
$rule : string
$parameters : array<string|int, mixed>
Return values
string

parseData()

Parse the data array, converting dots to ->.

public parseData(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
Return values
array<string|int, mixed>

passes()

Determine if the data passes the validation rules.

public passes() : bool
Return values
bool

setAttributeNames()

Set the custom attributes on the validator.

public setAttributeNames(array<string|int, mixed> $attributes) : $this
Parameters
$attributes : array<string|int, mixed>
Return values
$this

setContainer()

Set the IoC container instance.

public setContainer(Container $container) : void
Parameters
$container : Container
Return values
void

setCustomMessages()

Set the custom messages for the validator.

public setCustomMessages(array<string|int, mixed> $messages) : $this
Parameters
$messages : array<string|int, mixed>
Return values
$this

setData()

Set the data under validation.

public setData(array<string|int, mixed> $data) : $this
Parameters
$data : array<string|int, mixed>
Return values
$this

setFallbackMessages()

Set the fallback messages for the validator.

public setFallbackMessages(array<string|int, mixed> $messages) : void
Parameters
$messages : array<string|int, mixed>
Return values
void

setRules()

Set the validation rules.

public setRules(array<string|int, mixed> $rules) : $this
Parameters
$rules : array<string|int, mixed>
Return values
$this

setTranslator()

Set the Translator implementation.

public setTranslator(Translator $translator) : void
Parameters
$translator : Translator
Return values
void

setValueNames()

Set the custom values on the validator.

public setValueNames(array<string|int, mixed> $values) : $this
Parameters
$values : array<string|int, mixed>
Return values
$this

sometimes()

Add conditions to a given field based on a Closure.

public sometimes(string|array<string|int, mixed> $attribute, string|array<string|int, mixed> $rules, callable $callback) : $this
Parameters
$attribute : string|array<string|int, mixed>
$rules : string|array<string|int, mixed>
$callback : callable
Return values
$this

valid()

Returns the data which was valid.

public valid() : array<string|int, mixed>
Return values
array<string|int, mixed>

validateAccepted()

Validate that an attribute was "accepted".

public validateAccepted(string $attribute, mixed $value) : bool

This validation rule implies the attribute is "required".

Parameters
$attribute : string
$value : mixed
Return values
bool

validateActiveUrl()

Validate that an attribute is an active URL.

public validateActiveUrl(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateAfter()

Validate the date is after a given date.

public validateAfter(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateAfterOrEqual()

Validate the date is equal or after a given date.

public validateAfterOrEqual(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateAlpha()

Validate that an attribute contains only alphabetic characters.

public validateAlpha(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateAlphaDash()

Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.

public validateAlphaDash(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateAlphaNum()

Validate that an attribute contains only alpha-numeric characters.

public validateAlphaNum(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateArray()

Validate that an attribute is an array.

public validateArray(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateBail()

"Break" on first validation fail.

public validateBail() : bool

Always returns true, just lets us put "bail" in rules.

Return values
bool

validateBefore()

Validate the date is before a given date.

public validateBefore(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateBeforeOrEqual()

Validate the date is before or equal a given date.

public validateBeforeOrEqual(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateBetween()

Validate the size of an attribute is between a set of values.

public validateBetween(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateBoolean()

Validate that an attribute is a boolean.

public validateBoolean(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateConfirmed()

Validate that an attribute has a matching confirmation.

public validateConfirmed(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateDate()

Validate that an attribute is a valid date.

public validateDate(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateDateEquals()

Validate that an attribute is equal to another date.

public validateDateEquals(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateDateFormat()

Validate that an attribute matches a date format.

public validateDateFormat(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateDifferent()

Validate that an attribute is different from another attribute.

public validateDifferent(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateDigits()

Validate that an attribute has a given number of digits.

public validateDigits(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateDigitsBetween()

Validate that an attribute is between a given number of digits.

public validateDigitsBetween(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateDimensions()

Validate the dimensions of an image matches the given values.

public validateDimensions(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateDistinct()

Validate an attribute is unique among other values.

public validateDistinct(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateEmail()

Validate that an attribute is a valid e-mail address.

public validateEmail(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateExists()

Validate the existence of an attribute value in a database table.

public validateExists(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateFile()

Validate the given value is a valid file.

public validateFile(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateFilled()

Validate the given attribute is filled if it is present.

public validateFilled(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateImage()

Validate the MIME type of a file is an image MIME type.

public validateImage(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateIn()

Validate an attribute is contained within a list of values.

public validateIn(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateInArray()

Validate that the values of an attribute is in another attribute.

public validateInArray(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateInteger()

Validate that an attribute is an integer.

public validateInteger(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateIp()

Validate that an attribute is a valid IP.

public validateIp(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateIpv4()

Validate that an attribute is a valid IPv4.

public validateIpv4(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateIpv6()

Validate that an attribute is a valid IPv6.

public validateIpv6(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateJson()

Validate the attribute is a valid JSON string.

public validateJson(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateMax()

Validate the size of an attribute is less than a maximum value.

public validateMax(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateMimes()

Validate the guessed extension of a file upload is in a set of file extensions.

public validateMimes(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateMimetypes()

Validate the MIME type of a file upload attribute is in a set of MIME types.

public validateMimetypes(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateMin()

Validate the size of an attribute is greater than a minimum value.

public validateMin(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateNotIn()

Validate an attribute is not contained within a list of values.

public validateNotIn(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateNullable()

"Indicate" validation should pass if value is null.

public validateNullable() : bool

Always returns true, just lets us put "nullable" in rules.

Return values
bool

validateNumeric()

Validate that an attribute is numeric.

public validateNumeric(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validatePresent()

Validate that an attribute exists even if not filled.

public validatePresent(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateRegex()

Validate that an attribute passes a regular expression check.

public validateRegex(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateRequired()

Validate that a required attribute exists.

public validateRequired(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateRequiredIf()

Validate that an attribute exists when another attribute has a given value.

public validateRequiredIf(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : mixed
Return values
bool

validateRequiredUnless()

Validate that an attribute exists when another attribute does not have a given value.

public validateRequiredUnless(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : mixed
Return values
bool

validateRequiredWith()

Validate that an attribute exists when any other attribute exists.

public validateRequiredWith(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : mixed
Return values
bool

validateRequiredWithAll()

Validate that an attribute exists when all other attributes exists.

public validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : mixed
Return values
bool

validateRequiredWithout()

Validate that an attribute exists when another attribute does not.

public validateRequiredWithout(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : mixed
Return values
bool

validateRequiredWithoutAll()

Validate that an attribute exists when all other attributes do not.

public validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : mixed
Return values
bool

validateSame()

Validate that two attributes match.

public validateSame(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateSize()

Validate the size of an attribute.

public validateSize(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateSometimes()

"Validate" optional attributes.

public validateSometimes() : bool

Always returns true, just lets us put sometimes in rules.

Return values
bool

validateString()

Validate that an attribute is a string.

public validateString(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateTimezone()

Validate that an attribute is a valid timezone.

public validateTimezone(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

validateUnique()

Validate the uniqueness of an attribute value on a given database table.

public validateUnique(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool

If a database column is not specified, the attribute will be used.

Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

validateUrl()

Validate that an attribute is a valid URL.

public validateUrl(string $attribute, mixed $value) : bool
Parameters
$attribute : string
$value : mixed
Return values
bool

addFailure()

Add a failed rule and error message to the collection.

protected addFailure(string $attribute, string $rule, array<string|int, mixed> $parameters) : void
Parameters
$attribute : string
$rule : string
$parameters : array<string|int, mixed>
Return values
void

allFailingRequired()

Determine if all of the given attributes fail the required test.

protected allFailingRequired(array<string|int, mixed> $attributes) : bool
Parameters
$attributes : array<string|int, mixed>
Return values
bool

anyFailingRequired()

Determine if any of the given attributes fail the required test.

protected anyFailingRequired(array<string|int, mixed> $attributes) : bool
Parameters
$attributes : array<string|int, mixed>
Return values
bool

attributesThatHaveMessages()

Generate an array of all attributes that have messages.

protected attributesThatHaveMessages() : array<string|int, mixed>
Return values
array<string|int, mixed>

callClassBasedExtension()

Call a class based validator extension.

protected callClassBasedExtension(string $callback, array<string|int, mixed> $parameters) : bool
Parameters
$callback : string
$parameters : array<string|int, mixed>
Return values
bool

callClassBasedReplacer()

Call a class based validator message replacer.

protected callClassBasedReplacer(string $callback, string $message, string $attribute, string $rule, array<string|int, mixed> $parameters, Validator $validator) : string
Parameters
$callback : string
$message : string
$attribute : string
$rule : string
$parameters : array<string|int, mixed>
$validator : Validator
Return values
string

callExtension()

Call a custom validator extension.

protected callExtension(string $rule, array<string|int, mixed> $parameters) : bool|null
Parameters
$rule : string
$parameters : array<string|int, mixed>
Return values
bool|null

callReplacer()

Call a custom validator message replacer.

protected callReplacer(string $message, string $attribute, string $rule, array<string|int, mixed> $parameters, Validator $validator) : string|null
Parameters
$message : string
$attribute : string
$rule : string
$parameters : array<string|int, mixed>
$validator : Validator
Return values
string|null

checkDateTimeOrder()

Given two date/time strings, check that one is after the other.

protected checkDateTimeOrder(string $format, string $first, string $second, string $operator) : bool
Parameters
$format : string
$first : string
$second : string
$operator : string
Return values
bool

compare()

Determine if a comparison passes between the given values.

protected compare(mixed $first, mixed $second, string $operator) : bool
Parameters
$first : mixed
$second : mixed
$operator : string
Return values
bool

compareDates()

Compare a given date against another using an operator.

protected compareDates(string $attribute, mixed $value, array<string|int, mixed> $parameters, string $operator) : bool
Parameters
$attribute : string
$value : mixed
$parameters : array<string|int, mixed>
$operator : string
Return values
bool

convertValuesToBoolean()

Convert the given values to boolean if they are string "true" / "false".

protected convertValuesToBoolean(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
$values : array<string|int, mixed>
Return values
array<string|int, mixed>

dependsOnOtherFields()

Determine if the given rule depends on other fields.

protected dependsOnOtherFields(string $rule) : bool
Parameters
$rule : string
Return values
bool

failsBasicDimensionChecks()

Test if the given width and height fail any conditions.

protected failsBasicDimensionChecks(array<string|int, mixed> $parameters, int $width, int $height) : bool
Parameters
$parameters : array<string|int, mixed>
$width : int
$height : int
Return values
bool

failsRatioCheck()

Determine if the given parameters fail a dimension ratio check.

protected failsRatioCheck(array<string|int, mixed> $parameters, int $width, int $height) : bool
Parameters
$parameters : array<string|int, mixed>
$width : int
$height : int
Return values
bool

getAttributeFromTranslations()

Get the given attribute from the attribute translations.

protected getAttributeFromTranslations(string $name) : string
Parameters
$name : string
Return values
string

getAttributeList()

Transform an array of attributes to their displayable form.

protected getAttributeList(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
$values : array<string|int, mixed>
Return values
array<string|int, mixed>

getAttributeType()

Get the data type of the given attribute.

protected getAttributeType(string $attribute) : string
Parameters
$attribute : string
Return values
string

getCustomMessageFromTranslator()

Get the custom error message from translator.

protected getCustomMessageFromTranslator(string $key) : string
Parameters
$key : string
Return values
string

getDateFormat()

Get the date format for an attribute if it has one.

protected getDateFormat(string $attribute) : string|null
Parameters
$attribute : string
Return values
string|null

getDateTimestamp()

Get the date timestamp.

protected getDateTimestamp(mixed $value) : int
Parameters
$value : mixed
Return values
int

getDateTimeWithOptionalFormat()

Get a DateTime instance from a string.

protected getDateTimeWithOptionalFormat(string $format, string $value) : DateTime|null
Parameters
$format : string
$value : string
Return values
DateTime|null

getExistCount()

Get the number of records that exist in storage.

protected getExistCount(mixed $connection, string $table, string $column, mixed $value, array<string|int, mixed> $parameters) : int
Parameters
$connection : mixed
$table : string
$column : string
$value : mixed
$parameters : array<string|int, mixed>
Return values
int

getExplicitKeys()

Get the explicit keys from an attribute flattened with dot notation.

protected getExplicitKeys(string $attribute) : array<string|int, mixed>

E.g. 'foo.1.bar.spark.baz' -> [1, 'spark'] for 'foo..bar..baz'

Parameters
$attribute : string
Return values
array<string|int, mixed>

getExtraConditions()

Get the extra conditions for a unique / exists rule.

protected getExtraConditions(array<string|int, mixed> $segments) : array<string|int, mixed>
Parameters
$segments : array<string|int, mixed>
Return values
array<string|int, mixed>

getFromLocalArray()

Get the inline message for a rule if it exists.

protected getFromLocalArray(string $attribute, string $lowerRule[, array<string|int, mixed>|null $source = null ]) : string|null
Parameters
$attribute : string
$lowerRule : string
$source : array<string|int, mixed>|null = null
Return values
string|null

getInlineMessage()

Get the proper inline error message for standard and size rules.

protected getInlineMessage(string $attribute, string $rule) : string|null
Parameters
$attribute : string
$rule : string
Return values
string|null

getMessage()

Get the validation message for an attribute and rule.

protected getMessage(string $attribute, string $rule) : string
Parameters
$attribute : string
$rule : string
Return values
string

getPrimaryAttribute()

Get the primary attribute name.

protected getPrimaryAttribute(string $attribute) : string

For example, if "name.0" is given, "name.*" will be returned.

Parameters
$attribute : string
Return values
string

getQueryColumn()

Get the column name for an exists / unique query.

protected getQueryColumn(array<string|int, mixed> $parameters, string $attribute) : bool
Parameters
$parameters : array<string|int, mixed>
$attribute : string
Return values
bool

getRule()

Get a rule and its parameters for a given attribute.

protected getRule(string $attribute, string|array<string|int, mixed> $rules) : array<string|int, mixed>|null
Parameters
$attribute : string
$rules : string|array<string|int, mixed>
Return values
array<string|int, mixed>|null

getSize()

Get the size of an attribute.

protected getSize(string $attribute, mixed $value) : mixed
Parameters
$attribute : string
$value : mixed
Return values
mixed

getSizeMessage()

Get the proper error message for an attribute and size rule.

protected getSizeMessage(string $attribute, string $rule) : string
Parameters
$attribute : string
$rule : string
Return values
string

getUniqueExtra()

Get the extra conditions for a unique rule.

protected getUniqueExtra(array<string|int, mixed> $parameters) : array<string|int, mixed>
Parameters
$parameters : array<string|int, mixed>
Return values
array<string|int, mixed>

getUniqueIds()

Get the excluded ID column and value for the unique rule.

protected getUniqueIds(array<string|int, mixed> $parameters) : array<string|int, mixed>
Parameters
$parameters : array<string|int, mixed>
Return values
array<string|int, mixed>

getValue()

Get the value of a given attribute.

protected getValue(string $attribute) : mixed
Parameters
$attribute : string
Return values
mixed

getWildcardCustomMessages()

Check the given messages for a wildcard key.

protected getWildcardCustomMessages(array<string|int, mixed> $messages, string $search, string $default) : string
Parameters
$messages : array<string|int, mixed>
$search : string
$default : string
Return values
string

hasNotFailedPreviousRuleIfPresenceRule()

Determine if it's a necessary presence validation.

protected hasNotFailedPreviousRuleIfPresenceRule(string $rule, string $attribute) : bool

This is to avoid possible database type comparison errors.

Parameters
$rule : string
$attribute : string
Return values
bool

isImplicit()

Determine if a given rule implies the attribute is required.

protected isImplicit(object|string $rule) : bool
Parameters
$rule : object|string
Return values
bool

isNotNullIfMarkedAsNullable()

Determine if the attribute fails the nullable check.

protected isNotNullIfMarkedAsNullable(string $rule, string $attribute) : bool
Parameters
$rule : string
$attribute : string
Return values
bool

isValidatable()

Determine if the attribute is validatable.

protected isValidatable(object|string $rule, string $attribute, mixed $value) : bool
Parameters
$rule : object|string
$attribute : string
$value : mixed
Return values
bool

parseNamedParameters()

Parse named parameters to $key => $value items.

protected parseNamedParameters(array<string|int, mixed> $parameters) : array<string|int, mixed>
Parameters
$parameters : array<string|int, mixed>
Return values
array<string|int, mixed>

parseTable()

Parse the connection / table for the unique / exists rules.

protected parseTable(string $table) : array<string|int, mixed>
Parameters
$table : string
Return values
array<string|int, mixed>

passesOptionalCheck()

Determine if the attribute passes any optional check.

protected passesOptionalCheck(string $attribute) : bool
Parameters
$attribute : string
Return values
bool

prepareUniqueId()

Prepare the given ID for querying.

protected prepareUniqueId(mixed $id) : int
Parameters
$id : mixed
Return values
int

presentOrRuleIsImplicit()

Determine if the field is present, or the rule implies required.

protected presentOrRuleIsImplicit(object|string $rule, string $attribute, mixed $value) : bool
Parameters
$rule : object|string
$attribute : string
$value : mixed
Return values
bool

replaceAsterisksInParameters()

Replace each field parameter which has asterisks with the given keys.

protected replaceAsterisksInParameters(array<string|int, mixed> $parameters, array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$parameters : array<string|int, mixed>
$keys : array<string|int, mixed>
Return values
array<string|int, mixed>

replaceAttributePlaceholder()

Replace the :attribute placeholder in the given message.

protected replaceAttributePlaceholder(string $message, string $value) : string
Parameters
$message : string
$value : string
Return values
string

replaceInputPlaceholder()

Replace the :input placeholder in the given message.

protected replaceInputPlaceholder(string $message, string $attribute) : string
Parameters
$message : string
$attribute : string
Return values
string

requireParameterCount()

Require a certain number of parameters to be present.

protected requireParameterCount(int $count, array<string|int, mixed> $parameters, string $rule) : void
Parameters
$count : int
$parameters : array<string|int, mixed>
$rule : string
Tags
throws
InvalidArgumentException
Return values
void

shouldBlockPhpUpload()

Check if PHP uploads are explicitly allowed.

protected shouldBlockPhpUpload(mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
$value : mixed
$parameters : array<string|int, mixed>
Return values
bool

shouldStopValidating()

Check if we should stop further validations on a given attribute.

protected shouldStopValidating(string $attribute) : bool
Parameters
$attribute : string
Return values
bool

validateAttribute()

Validate a given attribute against a rule.

protected validateAttribute(string $attribute, string $rule) : void
Parameters
$attribute : string
$rule : string
Return values
void

validateUsingCustomRule()

Validate an attribute using a custom rule object.

protected validateUsingCustomRule(string $attribute, mixed $value, Rule $rule) : void
Parameters
$attribute : string
$value : mixed
$rule : Rule
Return values
void

Search results