PHP Class Overtrue\Validation\Validator

Datei anzeigen Open project: overtrue/validation Class Usage Examples

Protected Properties

Property Type Description
$after array All of the registered "after" callbacks.
$customAttributes array The array of custom attribute names.
$customMessages array The array of custom error messages.
$customValues array The array of custom displayabled values.
$data array The data under validation.
$extensions array All of the custom validator extensions.
$failedRules array The failed validation rules.
$fallbackMessages array The array of fallback error messages.
$files array The files under validation.
$implicitRules array The validation rules that imply the field is required.
$messages MessageBag The messages.
$numericRules array The numeric related validation rules.
$presenceVerifier Overtrue\Validation\PresenceVerifierInterface The Presence Verifier implementation.
$replacers array All of the custom replacer extensions.
$rules array The rules to be applied to the data.
$sizeRules array The size related validation rules.
$translator Overtrue\Validation\TranslatorInterface The Translator implementation.

Public Methods

Method Description
__call ( string $method, array $parameters ) : mixed Handle dynamic calls to class methods.
__construct ( Overtrue\Validation\TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = [] ) : Validator Create a new Validator instance.
addCustomAttributes ( array $customAttributes ) Add custom attributes to the validator.
addCustomValues ( array $customValues ) Add the custom values for the validator.
addExtension ( string $rule, Closure | string $extension ) Register a custom validator extension.
addExtensions ( array $extensions ) Register an array of custom validator extensions.
addImplicitExtension ( string $rule, Closure | string $extension ) Register a custom implicit validator extension.
addImplicitExtensions ( array $extensions ) Register an array of custom implicit validator extensions.
addReplacer ( string $rule, Closure | string $replacer ) Register a custom validator message replacer.
addReplacers ( array $replacers ) Register an array of custom validator message replacers.
after ( callable | string $callback ) After an after validation callback.
each ( string $attribute, string | array $rules ) Define a set of rules that apply to each element in an array attribute.
errors ( ) : MessageBag An alternative more semantic shortcut to the message container.
failed ( ) : array Get the failed validation rules.
fails ( ) : boolean Determine if the data fails the validation rules.
getCustomAttributes ( ) : array Get the custom attributes used by the validator.
getCustomMessages ( ) : array Get the custom messages for the validator.
getCustomValues ( ) : array Get the custom values for the validator.
getData ( ) : array Get the data under validation.
getDisplayableValue ( string $attribute, mixed $value ) : string Get the displayable name of the value.
getExtensions ( ) : array Get the array of custom validator extensions.
getFallbackMessages ( ) : array Get the fallback messages for the validator.
getFiles ( ) : array Get the files under validation.
getPresenceVerifier ( ) : Overtrue\Validation\PresenceVerifierInterface Get the Presence Verifier implementation.
getReplacers ( ) : array Get the array of custom validator message replacers.
getRules ( ) : array Get the validation rules.
getTranslator ( ) : Overtrue\Validation\TranslatorInterface Get the Translator implementation.
mergeRules ( string $attribute, string | array $rules ) Merge additional rules into a given attribute.
messages ( ) : MessageBag Get the message container for the validator.
passes ( ) : boolean Determine if the data passes the validation rules.
setAttributeNames ( array $attributes ) Set the custom attributes on the validator.
setCustomMessages ( array $messages ) Set the custom messages for the validator.
setData ( array $data ) Set the data under validation.
setFallbackMessages ( array $messages ) Set the fallback messages for the validator.
setFiles ( array $files ) Set the files under validation.
setPresenceVerifier ( Overtrue\Validation\PresenceVerifierInterface $presenceVerifier ) Set the Presence Verifier implementation.
setRules ( array $rules ) Set the validation rules.
setTranslator ( Overtrue\Validation\TranslatorInterface $translator ) Set the Translator implementation.
setValueNames ( array $values ) Set the custom values on the validator.
sometimes ( string $attribute, string | array $rules, callable $callback ) Add conditions to a given field based on a Closure.

Protected Methods

Method Description
addError ( string $attribute, string $rule, array $parameters ) Add an error message to the validator's collection of messages.
addFailure ( string $attribute, string $rule, array $parameters ) Add a failed rule and error message to the collection.
allFailingRequired ( array $attributes ) : boolean Determine if all of the given attributes fail the required test.
anyFailingRequired ( array $attributes ) : boolean Determine if any of the given attributes fail the required test.
callClassBasedExtension ( string $callback, array $parameters ) : boolean Call a class based validator extension.
callClassBasedReplacer ( string $callback, string $message, string $attribute, string $rule, array $parameters ) : string Call a class based validator message replacer.
callExtension ( string $rule, array $parameters ) : boolean Call a custom validator extension.
callReplacer ( string $message, string $attribute, string $rule, array $parameters ) : string Call a custom validator message replacer.
checkDateTimeOrder ( string $format, string $before, string $after ) : boolean Given two date/time strings, check that one is after the other.
doReplacements ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all error message place-holders with actual values.
explodeRules ( string | array $rules ) : array Explode the rules into an array of rules.
getAttribute ( string $attribute ) : string Get the displayable name of the attribute.
getAttributeList ( array $values ) : array Transform an array of attributes to their displayable form.
getAttributeType ( string $attribute ) : string Get the data type of the given attribute.
getDateFormat ( string $attribute ) : string | null Get the date format for an attribute if it has one.
getDateTimeWithOptionalFormat ( string $format, string $value ) : DateTime | null Get a DateTime instance from a string.
getExistCount ( string $table, string $column, mixed $value, array $parameters ) : integer Get the number of records that exist in storage.
getExtraConditions ( array $segments ) : array Get the extra conditions for a unique / exists rule.
getExtraExistConditions ( array $parameters ) : array Get the extra exist conditions.
getInlineMessage ( string $attribute, string $lowerRule, array $source = null ) : string Get the inline message for a rule if it exists.
getMessage ( string $attribute, string $rule ) : string Get the validation message for an attribute and rule.
getPresentCount ( array $attributes ) : integer Get the number of attributes in a list that are present.
getRule ( string $attribute, string | array $rules ) : array | null Get a rule and its parameters for a given attribute.
getSize ( string $attribute, mixed $value ) : mixed Get the size of an attribute.
getSizeMessage ( string $attribute, string $rule ) : string Get the proper error message for an attribute and size rule.
getStringSize ( string $value ) : integer Get the size of a string.
getUniqueExtra ( array $parameters ) : array Get the extra conditions for a unique rule.
getUniqueIds ( array $parameters ) : array Get the excluded ID column and value for the unique rule.
getValue ( string $attribute ) : mixed Get the value of a given attribute.
hasRule ( string $attribute, string | array $rules ) : boolean Determine if the given attribute has a rule in the given set.
isImplicit ( string $rule ) : boolean Determine if a given rule implies the attribute is required.
isValidatable ( string $rule, string $attribute, mixed $value ) : boolean Determine if the attribute is validatable.
parseArrayRule ( array $rules ) : array Parse an array based rule.
parseData ( array $data ) : array Parse the data and hydrate the files array.
parseParameters ( string $rule, string $parameter ) : array Parse a parameter list.
parseRule ( array | string $rules ) : array Extract the rule name and parameters from a rule.
parseStringRule ( string $rules ) : array Parse a string based rule.
passesOptionalCheck ( string $attribute ) : boolean Determine if the attribute passes any optional check.
presentOrRuleIsImplicit ( string $rule, string $attribute, mixed $value ) : boolean Determine if the field is present, or the rule implies required.
replaceAfter ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the after rule.
replaceBefore ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the before rule.
replaceBetween ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the between rule.
replaceDateFormat ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the date_format rule.
replaceDifferent ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the different rule.
replaceDigits ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the digits rule.
replaceDigitsBetween ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the digits (between) rule.
replaceIn ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the in rule.
replaceMax ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the max rule.
replaceMimes ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the mimes rule.
replaceMin ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the min rule.
replaceNotIn ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the not_in rule.
replaceRequiredIf ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the required_if rule.
replaceRequiredWith ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the required_with rule.
replaceRequiredWithAll ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the required_with_all rule.
replaceRequiredWithout ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the required_without rule.
replaceRequiredWithoutAll ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the required_without_all rule.
replaceSame ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the same rule.
replaceSize ( string $message, string $attribute, string $rule, array $parameters ) : string Replace all place-holders for the size rule.
requireParameterCount ( integer $count, array $parameters, string $rule ) Require a certain number of parameters to be present.
validate ( string $attribute, string $rule ) Validate a given attribute against a rule.
validateAccepted ( string $attribute, mixed $value ) : boolean Validate that an attribute was "accepted".
validateActiveUrl ( string $attribute, mixed $value ) : boolean Validate that an attribute is an active URL.
validateAfter ( string $attribute, mixed $value, array $parameters ) : boolean Validate the date is after a given date.
validateAfterWithFormat ( string $format, mixed $value, array $parameters ) : boolean Validate the date is after a given date with a given format.
validateAlpha ( string $attribute, mixed $value ) : boolean Validate that an attribute contains only alphabetic characters.
validateAlphaDash ( string $attribute, mixed $value ) : boolean Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
validateAlphaNum ( string $attribute, mixed $value ) : boolean Validate that an attribute contains only alpha-numeric characters.
validateArray ( string $attribute, mixed $value ) : boolean Validate that an attribute is an array.
validateBefore ( string $attribute, mixed $value, array $parameters ) : boolean Validate the date is before a given date.
validateBeforeWithFormat ( string $format, mixed $value, array $parameters ) : boolean Validate the date is before a given date with a given format.
validateBetween ( string $attribute, mixed $value, array $parameters ) : boolean Validate the size of an attribute is between a set of values.
validateBoolean ( string $attribute, mixed $value ) : boolean Validate that an attribute is a boolean.
validateConfirmed ( string $attribute, mixed $value ) : boolean Validate that an attribute has a matching confirmation.
validateDate ( string $attribute, mixed $value ) : boolean Validate that an attribute is a valid date.
validateDateFormat ( string $attribute, mixed $value, array $parameters ) : boolean Validate that an attribute matches a date format.
validateDifferent ( string $attribute, mixed $value, array $parameters ) : boolean Validate that an attribute is different from another attribute.
validateDigits ( string $attribute, mixed $value, array $parameters ) : boolean Validate that an attribute has a given number of digits.
validateDigitsBetween ( string $attribute, mixed $value, array $parameters ) : boolean Validate that an attribute is between a given number of digits.
validateEmail ( string $attribute, mixed $value ) : boolean Validate that an attribute is a valid e-mail address.
validateExists ( string $attribute, mixed $value, array $parameters ) : boolean Validate the existence of an attribute value in a database table.
validateFilled ( string $attribute, mixed $value ) : boolean Validate the given attribute is filled if it is present.
validateImage ( string $attribute, mixed $value ) : boolean Validate the MIME type of a file is an image MIME type.
validateIn ( string $attribute, mixed $value, array $parameters ) : boolean Validate an attribute is contained within a list of values.
validateInteger ( string $attribute, mixed $value ) : boolean Validate that an attribute is an integer.
validateIp ( string $attribute, mixed $value ) : boolean Validate that an attribute is a valid IP.
validateMax ( string $attribute, mixed $value, array $parameters ) : boolean Validate the size of an attribute is less than a maximum value.
validateMimes ( string $attribute, array $value, array $parameters ) : boolean Validate the MIME type of a file upload attribute is in a set of MIME types.
validateMin ( string $attribute, mixed $value, array $parameters ) : boolean Validate the size of an attribute is greater than a minimum value.
validateNotIn ( string $attribute, mixed $value, array $parameters ) : boolean Validate an attribute is not contained within a list of values.
validateNumeric ( string $attribute, mixed $value ) : boolean Validate that an attribute is numeric.
validateRegex ( string $attribute, mixed $value, array $parameters ) : boolean Validate that an attribute passes a regular expression check.
validateRequired ( string $attribute, mixed $value ) : boolean Validate that a required attribute exists.
validateRequiredIf ( string $attribute, mixed $value, mixed $parameters ) : boolean Validate that an attribute exists when another attribute has a given value.
validateRequiredWith ( string $attribute, mixed $value, mixed $parameters ) : boolean Validate that an attribute exists when any other attribute exists.
validateRequiredWithAll ( string $attribute, mixed $value, mixed $parameters ) : boolean Validate that an attribute exists when all other attributes exists.
validateRequiredWithout ( string $attribute, mixed $value, mixed $parameters ) : boolean Validate that an attribute exists when another attribute does not.
validateRequiredWithoutAll ( string $attribute, mixed $value, mixed $parameters ) : boolean Validate that an attribute exists when all other attributes do not.
validateSame ( string $attribute, mixed $value, array $parameters ) : boolean Validate that two attributes match.
validateSize ( string $attribute, mixed $value, array $parameters ) : boolean Validate the size of an attribute.
validateSometimes ( ) : boolean "Validate" optional attributes.
validateTimezone ( string $attribute, mixed $value ) : boolean Validate that an attribute is a valid timezone.
validateUnique ( string $attribute, mixed $value, array $parameters ) : boolean Validate the uniqueness of an attribute value on a given database table.
validateUrl ( string $attribute, mixed $value ) : boolean Validate that an attribute is a valid URL.

Method Details

__call() public method

Handle dynamic calls to class methods.
public __call ( string $method, array $parameters ) : mixed
$method string
$parameters array
return mixed

__construct() public method

Create a new Validator instance.
public __construct ( Overtrue\Validation\TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = [] ) : Validator
$translator Overtrue\Validation\TranslatorInterface
$data array
$rules array
$messages array
$customAttributes array
return Validator

addCustomAttributes() public method

Add custom attributes to the validator.
public addCustomAttributes ( array $customAttributes )
$customAttributes array

addCustomValues() public method

Add the custom values for the validator.
public addCustomValues ( array $customValues )
$customValues array

addError() protected method

Add an error message to the validator's collection of messages.
protected addError ( string $attribute, string $rule, array $parameters )
$attribute string
$rule string
$parameters array

addExtension() public method

Register a custom validator extension.
public addExtension ( string $rule, Closure | string $extension )
$rule string
$extension Closure | string

addExtensions() public method

Register an array of custom validator extensions.
public addExtensions ( array $extensions )
$extensions array

addFailure() protected method

Add a failed rule and error message to the collection.
protected addFailure ( string $attribute, string $rule, array $parameters )
$attribute string
$rule string
$parameters array

addImplicitExtension() public method

Register a custom implicit validator extension.
public addImplicitExtension ( string $rule, Closure | string $extension )
$rule string
$extension Closure | string

addImplicitExtensions() public method

Register an array of custom implicit validator extensions.
public addImplicitExtensions ( array $extensions )
$extensions array

addReplacer() public method

Register a custom validator message replacer.
public addReplacer ( string $rule, Closure | string $replacer )
$rule string
$replacer Closure | string

addReplacers() public method

Register an array of custom validator message replacers.
public addReplacers ( array $replacers )
$replacers array

after() public method

After an after validation callback.
public after ( callable | string $callback )
$callback callable | string

allFailingRequired() protected method

Determine if all of the given attributes fail the required test.
protected allFailingRequired ( array $attributes ) : boolean
$attributes array
return boolean

anyFailingRequired() protected method

Determine if any of the given attributes fail the required test.
protected anyFailingRequired ( array $attributes ) : boolean
$attributes array
return boolean

callClassBasedExtension() protected method

Call a class based validator extension.
protected callClassBasedExtension ( string $callback, array $parameters ) : boolean
$callback string
$parameters array
return boolean

callClassBasedReplacer() protected method

Call a class based validator message replacer.
protected callClassBasedReplacer ( string $callback, string $message, string $attribute, string $rule, array $parameters ) : string
$callback string
$message string
$attribute string
$rule string
$parameters array
return string

callExtension() protected method

Call a custom validator extension.
protected callExtension ( string $rule, array $parameters ) : boolean
$rule string
$parameters array
return boolean

callReplacer() protected method

Call a custom validator message replacer.
protected callReplacer ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

checkDateTimeOrder() protected method

Given two date/time strings, check that one is after the other.
protected checkDateTimeOrder ( string $format, string $before, string $after ) : boolean
$format string
$before string
$after string
return boolean

doReplacements() protected method

Replace all error message place-holders with actual values.
protected doReplacements ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

each() public method

Define a set of rules that apply to each element in an array attribute.
public each ( string $attribute, string | array $rules )
$attribute string
$rules string | array

errors() public method

An alternative more semantic shortcut to the message container.
public errors ( ) : MessageBag
return MessageBag

explodeRules() protected method

Explode the rules into an array of rules.
protected explodeRules ( string | array $rules ) : array
$rules string | array
return array

failed() public method

Get the failed validation rules.
public failed ( ) : array
return array

fails() public method

Determine if the data fails the validation rules.
public fails ( ) : boolean
return boolean

getAttribute() protected method

Get the displayable name of the attribute.
protected getAttribute ( string $attribute ) : string
$attribute string
return string

getAttributeList() protected method

Transform an array of attributes to their displayable form.
protected getAttributeList ( array $values ) : array
$values array
return array

getAttributeType() protected method

Get the data type of the given attribute.
protected getAttributeType ( string $attribute ) : string
$attribute string
return string

getCustomAttributes() public method

Get the custom attributes used by the validator.
public getCustomAttributes ( ) : array
return array

getCustomMessages() public method

Get the custom messages for the validator.
public getCustomMessages ( ) : array
return array

getCustomValues() public method

Get the custom values for the validator.
public getCustomValues ( ) : array
return array

getData() public method

Get the data under validation.
public getData ( ) : array
return array

getDateFormat() protected method

Get the date format for an attribute if it has one.
protected getDateFormat ( string $attribute ) : string | null
$attribute string
return string | null

getDateTimeWithOptionalFormat() protected method

Get a DateTime instance from a string.
protected getDateTimeWithOptionalFormat ( string $format, string $value ) : DateTime | null
$format string
$value string
return DateTime | null

getDisplayableValue() public method

Get the displayable name of the value.
public getDisplayableValue ( string $attribute, mixed $value ) : string
$attribute string
$value mixed
return string

getExistCount() protected method

Get the number of records that exist in storage.
protected getExistCount ( string $table, string $column, mixed $value, array $parameters ) : integer
$table string
$column string
$value mixed
$parameters array
return integer

getExtensions() public method

Get the array of custom validator extensions.
public getExtensions ( ) : array
return array

getExtraConditions() protected method

Get the extra conditions for a unique / exists rule.
protected getExtraConditions ( array $segments ) : array
$segments array
return array

getExtraExistConditions() protected method

Get the extra exist conditions.
protected getExtraExistConditions ( array $parameters ) : array
$parameters array
return array

getFallbackMessages() public method

Get the fallback messages for the validator.
public getFallbackMessages ( ) : array
return array

getFiles() public method

Get the files under validation.
public getFiles ( ) : array
return array

getInlineMessage() protected method

Get the inline message for a rule if it exists.
protected getInlineMessage ( string $attribute, string $lowerRule, array $source = null ) : string
$attribute string
$lowerRule string
$source array
return string

getMessage() protected method

Get the validation message for an attribute and rule.
protected getMessage ( string $attribute, string $rule ) : string
$attribute string
$rule string
return string

getPresenceVerifier() public method

Get the Presence Verifier implementation.
public getPresenceVerifier ( ) : Overtrue\Validation\PresenceVerifierInterface
return Overtrue\Validation\PresenceVerifierInterface

getPresentCount() protected method

Get the number of attributes in a list that are present.
protected getPresentCount ( array $attributes ) : integer
$attributes array
return integer

getReplacers() public method

Get the array of custom validator message replacers.
public getReplacers ( ) : array
return array

getRule() protected method

Get a rule and its parameters for a given attribute.
protected getRule ( string $attribute, string | array $rules ) : array | null
$attribute string
$rules string | array
return array | null

getRules() public method

Get the validation rules.
public getRules ( ) : array
return array

getSize() protected method

Get the size of an attribute.
protected getSize ( string $attribute, mixed $value ) : mixed
$attribute string
$value mixed
return mixed

getSizeMessage() protected method

Get the proper error message for an attribute and size rule.
protected getSizeMessage ( string $attribute, string $rule ) : string
$attribute string
$rule string
return string

getStringSize() protected method

Get the size of a string.
protected getStringSize ( string $value ) : integer
$value string
return integer

getTranslator() public method

Get the Translator implementation.
public getTranslator ( ) : Overtrue\Validation\TranslatorInterface
return Overtrue\Validation\TranslatorInterface

getUniqueExtra() protected method

Get the extra conditions for a unique rule.
protected getUniqueExtra ( array $parameters ) : array
$parameters array
return array

getUniqueIds() protected method

Get the excluded ID column and value for the unique rule.
protected getUniqueIds ( array $parameters ) : array
$parameters array
return array

getValue() protected method

Get the value of a given attribute.
protected getValue ( string $attribute ) : mixed
$attribute string
return mixed

hasRule() protected method

Determine if the given attribute has a rule in the given set.
protected hasRule ( string $attribute, string | array $rules ) : boolean
$attribute string
$rules string | array
return boolean

isImplicit() protected method

Determine if a given rule implies the attribute is required.
protected isImplicit ( string $rule ) : boolean
$rule string
return boolean

isValidatable() protected method

Determine if the attribute is validatable.
protected isValidatable ( string $rule, string $attribute, mixed $value ) : boolean
$rule string
$attribute string
$value mixed
return boolean

mergeRules() public method

Merge additional rules into a given attribute.
public mergeRules ( string $attribute, string | array $rules )
$attribute string
$rules string | array

messages() public method

Get the message container for the validator.
public messages ( ) : MessageBag
return MessageBag

parseArrayRule() protected method

Parse an array based rule.
protected parseArrayRule ( array $rules ) : array
$rules array
return array

parseData() protected method

Parse the data and hydrate the files array.
protected parseData ( array $data ) : array
$data array
return array

parseParameters() protected method

Parse a parameter list.
protected parseParameters ( string $rule, string $parameter ) : array
$rule string
$parameter string
return array

parseRule() protected method

Extract the rule name and parameters from a rule.
protected parseRule ( array | string $rules ) : array
$rules array | string
return array

parseStringRule() protected method

Parse a string based rule.
protected parseStringRule ( string $rules ) : array
$rules string
return array

passes() public method

Determine if the data passes the validation rules.
public passes ( ) : boolean
return boolean

passesOptionalCheck() protected method

Determine if the attribute passes any optional check.
protected passesOptionalCheck ( string $attribute ) : boolean
$attribute string
return boolean

presentOrRuleIsImplicit() protected method

Determine if the field is present, or the rule implies required.
protected presentOrRuleIsImplicit ( string $rule, string $attribute, mixed $value ) : boolean
$rule string
$attribute string
$value mixed
return boolean

replaceAfter() protected method

Replace all place-holders for the after rule.
protected replaceAfter ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceBefore() protected method

Replace all place-holders for the before rule.
protected replaceBefore ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceBetween() protected method

Replace all place-holders for the between rule.
protected replaceBetween ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceDateFormat() protected method

Replace all place-holders for the date_format rule.
protected replaceDateFormat ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceDifferent() protected method

Replace all place-holders for the different rule.
protected replaceDifferent ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceDigits() protected method

Replace all place-holders for the digits rule.
protected replaceDigits ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceDigitsBetween() protected method

Replace all place-holders for the digits (between) rule.
protected replaceDigitsBetween ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceIn() protected method

Replace all place-holders for the in rule.
protected replaceIn ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceMax() protected method

Replace all place-holders for the max rule.
protected replaceMax ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceMimes() protected method

Replace all place-holders for the mimes rule.
protected replaceMimes ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceMin() protected method

Replace all place-holders for the min rule.
protected replaceMin ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceNotIn() protected method

Replace all place-holders for the not_in rule.
protected replaceNotIn ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceRequiredIf() protected method

Replace all place-holders for the required_if rule.
protected replaceRequiredIf ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceRequiredWith() protected method

Replace all place-holders for the required_with rule.
protected replaceRequiredWith ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceRequiredWithAll() protected method

Replace all place-holders for the required_with_all rule.
protected replaceRequiredWithAll ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceRequiredWithout() protected method

Replace all place-holders for the required_without rule.
protected replaceRequiredWithout ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceRequiredWithoutAll() protected method

Replace all place-holders for the required_without_all rule.
protected replaceRequiredWithoutAll ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceSame() protected method

Replace all place-holders for the same rule.
protected replaceSame ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceSize() protected method

Replace all place-holders for the size rule.
protected replaceSize ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

requireParameterCount() protected method

Require a certain number of parameters to be present.
protected requireParameterCount ( integer $count, array $parameters, string $rule )
$count integer
$parameters array
$rule string

setAttributeNames() public method

Set the custom attributes on the validator.
public setAttributeNames ( array $attributes )
$attributes array

setCustomMessages() public method

Set the custom messages for the validator.
public setCustomMessages ( array $messages )
$messages array

setData() public method

Set the data under validation.
public setData ( array $data )
$data array

setFallbackMessages() public method

Set the fallback messages for the validator.
public setFallbackMessages ( array $messages )
$messages array

setFiles() public method

Set the files under validation.
public setFiles ( array $files )
$files array

setPresenceVerifier() public method

Set the Presence Verifier implementation.
public setPresenceVerifier ( Overtrue\Validation\PresenceVerifierInterface $presenceVerifier )
$presenceVerifier Overtrue\Validation\PresenceVerifierInterface

setRules() public method

Set the validation rules.
public setRules ( array $rules )
$rules array

setTranslator() public method

Set the Translator implementation.
public setTranslator ( Overtrue\Validation\TranslatorInterface $translator )
$translator Overtrue\Validation\TranslatorInterface

setValueNames() public method

Set the custom values on the validator.
public setValueNames ( array $values )
$values array

sometimes() public method

Add conditions to a given field based on a Closure.
public sometimes ( string $attribute, string | array $rules, callable $callback )
$attribute string
$rules string | array
$callback callable

validate() protected method

Validate a given attribute against a rule.
protected validate ( string $attribute, string $rule )
$attribute string
$rule string

validateAccepted() protected method

This validation rule implies the attribute is "required".
protected validateAccepted ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateActiveUrl() protected method

Validate that an attribute is an active URL.
protected validateActiveUrl ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateAfter() protected method

Validate the date is after a given date.
protected validateAfter ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateAfterWithFormat() protected method

Validate the date is after a given date with a given format.
protected validateAfterWithFormat ( string $format, mixed $value, array $parameters ) : boolean
$format string
$value mixed
$parameters array
return boolean

validateAlpha() protected method

Validate that an attribute contains only alphabetic characters.
protected validateAlpha ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateAlphaDash() protected method

Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
protected validateAlphaDash ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateAlphaNum() protected method

Validate that an attribute contains only alpha-numeric characters.
protected validateAlphaNum ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateArray() protected method

Validate that an attribute is an array.
protected validateArray ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateBefore() protected method

Validate the date is before a given date.
protected validateBefore ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateBeforeWithFormat() protected method

Validate the date is before a given date with a given format.
protected validateBeforeWithFormat ( string $format, mixed $value, array $parameters ) : boolean
$format string
$value mixed
$parameters array
return boolean

validateBetween() protected method

Validate the size of an attribute is between a set of values.
protected validateBetween ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateBoolean() protected method

Validate that an attribute is a boolean.
protected validateBoolean ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateConfirmed() protected method

Validate that an attribute has a matching confirmation.
protected validateConfirmed ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateDate() protected method

Validate that an attribute is a valid date.
protected validateDate ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateDateFormat() protected method

Validate that an attribute matches a date format.
protected validateDateFormat ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateDifferent() protected method

Validate that an attribute is different from another attribute.
protected validateDifferent ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateDigits() protected method

Validate that an attribute has a given number of digits.
protected validateDigits ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateDigitsBetween() protected method

Validate that an attribute is between a given number of digits.
protected validateDigitsBetween ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateEmail() protected method

Validate that an attribute is a valid e-mail address.
protected validateEmail ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateExists() protected method

Validate the existence of an attribute value in a database table.
protected validateExists ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateFilled() protected method

Validate the given attribute is filled if it is present.
protected validateFilled ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateImage() protected method

Validate the MIME type of a file is an image MIME type.
protected validateImage ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateIn() protected method

Validate an attribute is contained within a list of values.
protected validateIn ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateInteger() protected method

Validate that an attribute is an integer.
protected validateInteger ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateIp() protected method

Validate that an attribute is a valid IP.
protected validateIp ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateMax() protected method

Validate the size of an attribute is less than a maximum value.
protected validateMax ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateMimes() protected method

Validate the MIME type of a file upload attribute is in a set of MIME types.
protected validateMimes ( string $attribute, array $value, array $parameters ) : boolean
$attribute string
$value array
$parameters array
return boolean

validateMin() protected method

Validate the size of an attribute is greater than a minimum value.
protected validateMin ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateNotIn() protected method

Validate an attribute is not contained within a list of values.
protected validateNotIn ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateNumeric() protected method

Validate that an attribute is numeric.
protected validateNumeric ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateRegex() protected method

Validate that an attribute passes a regular expression check.
protected validateRegex ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateRequired() protected method

Validate that a required attribute exists.
protected validateRequired ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateRequiredIf() protected method

Validate that an attribute exists when another attribute has a given value.
protected validateRequiredIf ( string $attribute, mixed $value, mixed $parameters ) : boolean
$attribute string
$value mixed
$parameters mixed
return boolean

validateRequiredWith() protected method

Validate that an attribute exists when any other attribute exists.
protected validateRequiredWith ( string $attribute, mixed $value, mixed $parameters ) : boolean
$attribute string
$value mixed
$parameters mixed
return boolean

validateRequiredWithAll() protected method

Validate that an attribute exists when all other attributes exists.
protected validateRequiredWithAll ( string $attribute, mixed $value, mixed $parameters ) : boolean
$attribute string
$value mixed
$parameters mixed
return boolean

validateRequiredWithout() protected method

Validate that an attribute exists when another attribute does not.
protected validateRequiredWithout ( string $attribute, mixed $value, mixed $parameters ) : boolean
$attribute string
$value mixed
$parameters mixed
return boolean

validateRequiredWithoutAll() protected method

Validate that an attribute exists when all other attributes do not.
protected validateRequiredWithoutAll ( string $attribute, mixed $value, mixed $parameters ) : boolean
$attribute string
$value mixed
$parameters mixed
return boolean

validateSame() protected method

Validate that two attributes match.
protected validateSame ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateSize() protected method

Validate the size of an attribute.
protected validateSize ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateSometimes() protected method

Always returns true, just lets us put sometimes in rules.
protected validateSometimes ( ) : boolean
return boolean

validateTimezone() protected method

Validate that an attribute is a valid timezone.
protected validateTimezone ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

validateUnique() protected method

If a database column is not specified, the attribute will be used.
protected validateUnique ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean

validateUrl() protected method

Validate that an attribute is a valid URL.
protected validateUrl ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

Property Details

$after protected_oe property

All of the registered "after" callbacks.
protected array $after
return array

$customAttributes protected_oe property

The array of custom attribute names.
protected array $customAttributes
return array

$customMessages protected_oe property

The array of custom error messages.
protected array $customMessages
return array

$customValues protected_oe property

The array of custom displayabled values.
protected array $customValues
return array

$data protected_oe property

The data under validation.
protected array $data
return array

$extensions protected_oe property

All of the custom validator extensions.
protected array $extensions
return array

$failedRules protected_oe property

The failed validation rules.
protected array $failedRules
return array

$fallbackMessages protected_oe property

The array of fallback error messages.
protected array $fallbackMessages
return array

$files protected_oe property

The files under validation.
protected array $files
return array

$implicitRules protected_oe property

The validation rules that imply the field is required.
protected array $implicitRules
return array

$messages protected_oe property

The messages.
protected MessageBag,Overtrue\Validation $messages
return MessageBag

$numericRules protected_oe property

The numeric related validation rules.
protected array $numericRules
return array

$presenceVerifier protected_oe property

The Presence Verifier implementation.
protected PresenceVerifierInterface,Overtrue\Validation $presenceVerifier
return Overtrue\Validation\PresenceVerifierInterface

$replacers protected_oe property

All of the custom replacer extensions.
protected array $replacers
return array

$rules protected_oe property

The rules to be applied to the data.
protected array $rules
return array

$sizeRules protected_oe property

The size related validation rules.
protected array $sizeRules
return array

$translator protected_oe property

The Translator implementation.
protected TranslatorInterface,Overtrue\Validation $translator
return Overtrue\Validation\TranslatorInterface