Validator
Implements
Uses
Properties
$presenceVerifier PresenceVerifierInterface
The Presence Verifier implementation.
$failedRules array
The failed validation rules.
$excludeAttributes array
Attributes that should be excluded from the validated data.
$data array
The data under validation.
$initialRules array
The initial rules provided.
$rules array
The rules to be applied to the data.
$currentRule string
The current rule that is validating.
$implicitAttributes array
The array of wildcard attributes with their asterisks expanded.
$implicitAttributesFormatter callable|null
The callback that should be used to format the attribute.
$distinctValues array
The cached data for the "distinct" rule.
$after array
All of the registered "after" callbacks.
$customMessages array
The array of custom error messages.
$fallbackMessages array
The array of fallback error messages.
$customAttributes array
The array of custom attribute names.
$customValues array
The array of custom displayable values.
$stopOnFirstFailure bool
Indicates if the validator should stop on the first rule failure.
$excludeUnvalidatedArrayKeys bool
Indicates that unvalidated array keys should be excluded, even if the parent array was validated.
$extensions array
All of the custom validator extensions.
$replacers array
All of the custom replacer extensions.
$fileRules string[]
The validation rules that may be applied to files.
$implicitRules string[]
The validation rules that imply the field is required.
$dependentRules string[]
The validation rules which depend on other fields as parameters.
$excludeRules string[]
The validation rules that can exclude an attribute.
$sizeRules string[]
The size related validation rules.
$numericRules string[]
The numeric related validation rules.
$dotPlaceholder string
The current placeholder for dots in rule keys.
$exception string
The exception to throw upon failure.
Methods
__construct ( Translator $translator , array $data , array $rules , array $messages , array $customAttributes ) : void
Create a new Validator instance.
Parameters
- $translator Translator
- $data array
- $rules array
- $messages array
- $customAttributes array
parseData ( array $data ) : array
Parse the data array, converting dots and asterisks.
Parameters
- $data array
replacePlaceholders ( $data ) : array
Replace the placeholders used in data keys.
Parameters
- $data array
replacePlaceholderInString ( string $value ) : string
Replace the placeholders in the given string.
Parameters
- $value string
after ( $callback ) : $this
Add an after validation callback.
Parameters
- $callback callable|string
passes ( ) : bool
Determine if the data passes the validation rules.
fails ( ) : bool
Determine if the data fails the validation rules.
shouldBeExcluded ( $attribute ) : bool
Determine if the attribute should be excluded.
Parameters
- $attribute string
removeAttribute ( $attribute ) : void
Remove the given attribute.
Parameters
- $attribute string
validate ( ) : array
Run the validator's rules against its data.
validateWithBag ( string $errorBag ) : array
Run the validator's rules against its data.
Parameters
- $errorBag string
safe ( array $keys ) : ValidatedInput |array
Get a validated input container for the validated input.
Parameters
- $keys array|null
validated ( ) : array
Get the attributes and values that were validated.
validateAttribute ( $attribute , $rule ) : void
Validate a given attribute against a rule.
Parameters
- $attribute string
- $rule string
dependsOnOtherFields ( $rule ) : bool
Determine if the given rule depends on other fields.
Parameters
- $rule string
getExplicitKeys ( $attribute ) : array
Get the explicit keys from an attribute flattened with dot notation.
Parameters
- $attribute string
getPrimaryAttribute ( $attribute ) : string
Get the primary attribute name.
Parameters
- $attribute string
replaceDotInParameters ( array $parameters ) : array
Replace each field parameter which has an escaped dot with the dot placeholder.
Parameters
- $parameters array
- $keys array
replaceAsterisksInParameters ( array $parameters , array $keys ) : array
Replace each field parameter which has asterisks with the given keys.
Parameters
- $parameters array
- $keys array
isValidatable ( $rule , $attribute , $value ) : bool
Determine if the attribute is validatable.
Parameters
- $rule object|string
- $attribute string
- $value mixed
presentOrRuleIsImplicit ( $rule , $attribute , $value ) : bool
Determine if the field is present, or the rule implies required.
Parameters
- $rule object|string
- $attribute string
- $value mixed
isImplicit ( $rule ) : bool
Determine if a given rule implies the attribute is required.
Parameters
- $rule object|string
passesOptionalCheck ( $attribute ) : bool
Determine if the attribute passes any optional check.
Parameters
- $attribute string
isNotNullIfMarkedAsNullable ( $rule , $attribute ) : bool
Determine if the attribute fails the nullable check.
Parameters
- $rule string
- $attribute string
hasNotFailedPreviousRuleIfPresenceRule ( $rule , $attribute ) : bool
Determine if it's a necessary presence validation.
Parameters
- $rule string
- $attribute string
validateUsingCustomRule ( $attribute , $value , $rule ) : void
Validate an attribute using a custom rule object.
Parameters
- $attribute string
- $value mixed
- $rule Rule
shouldStopValidating ( $attribute ) : bool
Check if we should stop further validations on a given attribute.
Parameters
- $attribute string
addFailure ( $attribute , $rule , $parameters ) : void
Add a failed rule and error message to the collection.
Parameters
- $attribute string
- $rule string
- $parameters array
excludeAttribute ( string $attribute ) : void
Add the given attribute to the list of excluded attributes.
Parameters
- $attribute string
valid ( ) : array
Returns the data which was valid.
invalid ( ) : array
Returns the data which was invalid.
attributesThatHaveMessages ( ) : array
Generate an array of all attributes that have messages.
failed ( ) : array
Get the failed validation rules.
hasRule ( $attribute , $rules ) : bool
Determine if the given attribute has a rule in the given set.
Parameters
- $attribute string
- $rules string|array
getRule ( $attribute , $rules ) : array|null
Get a rule and its parameters for a given attribute.
Parameters
- $attribute string
- $rules string|array
attributes ( ) : array
Get the data under validation.
getData ( ) : array
Get the data under validation.
setData ( array $data ) : $this
Set the data under validation.
Parameters
- $data array
getValue ( $attribute ) : mixed
Get the value of a given attribute.
Parameters
- $attribute string
getRules ( ) : array
Get the validation rules.
setRules ( array $rules ) : $this
Set the validation rules.
Parameters
- $rules array
addRules ( $rules ) : void
Parse the given rules and merge them into current rules.
Parameters
- $rules array
sometimes ( $attribute , $rules , callable $callback ) : $this
Add conditions to a given field based on a Closure.
Parameters
- $attribute string|array
- $rules string|array
- $callback callable
dataForSometimesIteration ( string $attribute , $removeLastSegmentOfAttribute ) : Fluent |array|mixed
Get the data that should be injected into the iteration of a wildcard "sometimes" callback.
Parameters
- $attribute string
stopOnFirstFailure ( $stopOnFirstFailure ) : $this
Instruct the validator to stop validating after the first rule failure.
Parameters
- $stopOnFirstFailure bool
addExtensions ( array $extensions ) : void
Register an array of custom validator extensions.
Parameters
- $extensions array
addImplicitExtensions ( array $extensions ) : void
Register an array of custom implicit validator extensions.
Parameters
- $extensions array
addDependentExtensions ( array $extensions ) : void
Register an array of custom dependent validator extensions.
Parameters
- $extensions array
addExtension ( $rule , $extension ) : void
Register a custom validator extension.
Parameters
- $rule string
- $extension Closure |string
addImplicitExtension ( $rule , $extension ) : void
Register a custom implicit validator extension.
Parameters
- $rule string
- $extension Closure |string
addDependentExtension ( $rule , $extension ) : void
Register a custom dependent validator extension.
Parameters
- $rule string
- $extension Closure |string
addReplacers ( array $replacers ) : void
Register an array of custom validator message replacers.
Parameters
- $replacers array
addReplacer ( $rule , $replacer ) : void
Register a custom validator message replacer.
Parameters
- $rule string
- $replacer Closure |string
setCustomMessages ( array $messages ) : $this
Set the custom messages for the validator.
Parameters
- $messages array
setAttributeNames ( array $attributes ) : $this
Set the custom attributes on the validator.
Parameters
- $attributes array
addCustomAttributes ( array $customAttributes ) : $this
Add custom attributes to the validator.
Parameters
- $customAttributes array
setImplicitAttributesFormatter ( callable $formatter ) : $this
Set the callback that used to format an implicit attribute.
Parameters
- $formatter callable|null
setValueNames ( array $values ) : $this
Set the custom values on the validator.
Parameters
- $values array
addCustomValues ( array $customValues ) : $this
Add the custom values for the validator.
Parameters
- $customValues array
setFallbackMessages ( array $messages ) : void
Set the fallback messages for the validator.
Parameters
- $messages array
getPresenceVerifier ( $connection ) : PresenceVerifierInterface
Get the Presence Verifier implementation.
Parameters
- $connection string|null
setPresenceVerifier ( PresenceVerifierInterface $presenceVerifier ) : void
Set the Presence Verifier implementation.
Parameters
- $presenceVerifier PresenceVerifierInterface
setException ( $exception ) : $this
Set the exception to throw upon failed validation.
Parameters
- $exception string
setTranslator ( Translator $translator ) : void
Set the Translator implementation.
Parameters
- $translator Translator
setContainer ( Container $container ) : void
Set the IoC container instance.
Parameters
- $container Container
callExtension ( $rule , $parameters ) : bool|null
Call a custom validator extension.
Parameters
- $rule string
- $parameters array
callClassBasedExtension ( $callback , $parameters ) : bool
Call a class based validator extension.
Parameters
- $callback string
- $parameters array
__call ( $method , $parameters ) : mixed
Handle dynamic calls to class methods.
Parameters
- $method string
- $parameters array