Validator (Validation)
Validator
class Validator implements Validator (View source)
Traits
FormatsMessages |
ValidatesAttributes |
ReplacesAttributes |
Properties
array | $customMessages | The array of custom error messages. | |
array | $fallbackMessages | The array of fallback error messages. | |
array | $customAttributes | The array of custom attribute names. | |
array | $customValues | The array of custom displayable values. | |
array | $extensions | All of the custom validator extensions. | |
array | $replacers | All of the custom replacer extensions. |
Methods
string | makeReplacements(string $message, string $attribute, string $rule, array $parameters) Replace all error message place-holders with actual values. | from FormatsMessages |
string | getDisplayableAttribute(string $attribute) Get the displayable name of the attribute. | from FormatsMessages |
string | getDisplayableValue(string $attribute, mixed $value) Get the displayable name of the value. | from FormatsMessages |
string | guessColumnForQuery(string $attribute) Guess the database column from the given attribute name. | from ValidatesAttributes |
bool | isValidFileInstance(mixed $value) Check that the given value is a valid file instance. | from ValidatesAttributes |
void | __construct(Translator $translator, array $data, array $rules, array $messages = array(), array $customAttributes = array()) Create a new Validator instance. | |
array | parseData(array $data) Parse the data array, converting dots to ->. | |
$this | after(callable|string $callback) Add an after validation callback. | |
bool | passes() Determine if the data passes the validation rules. | |
bool | fails() Determine if the data fails the validation rules. | |
void | validate() Run the validator's rules against its data. | |
array | valid() Returns the data which was valid. | |
array | invalid() Returns the data which was invalid. | |
array | failed() Get the failed validation rules. | |
MessageBag | messages() Get the message container for the validator. | |
MessageBag | errors() An alternative more semantic shortcut to the message container. | |
MessageBag | getMessageBag() Get the messages for the instance. | |
bool | hasRule(string $attribute, string|array $rules) Determine if the given attribute has a rule in the given set. | |
array | attributes() Get the data under validation. | |
array | getData() Get the data under validation. | |
$this | setData(array $data) Set the data under validation. | |
array | getRules() Get the validation rules. | |
$this | setRules(array $rules) Set the validation rules. | |
void | addRules(array $rules) Parse the given rules and merge them into current rules. | |
$this | sometimes(string $attribute, string|array $rules, callable $callback) Add conditions to a given field based on a Closure. | |
void | addExtensions(array $extensions) Register an array of custom validator extensions. | |
void | addImplicitExtensions(array $extensions) Register an array of custom implicit validator extensions. | |
void | addDependentExtensions(array $extensions) Register an array of custom implicit validator extensions. | |
void | addExtension(string $rule, Closure|string $extension) Register a custom validator extension. | |
void | addImplicitExtension(string $rule, Closure|string $extension) Register a custom implicit validator extension. | |
void | addDependentExtension(string $rule, Closure|string $extension) Register a custom dependent validator extension. | |
void | addReplacers(array $replacers) Register an array of custom validator message replacers. | |
void | addReplacer(string $rule, Closure|string $replacer) Register a custom validator message replacer. | |
void | setCustomMessages(array $messages) Set the custom messages for the validator. | |
$this | setAttributeNames(array $attributes) Set the custom attributes on the validator. | |
$this | addCustomAttributes(array $customAttributes) Add custom attributes to the validator. | |
$this | setValueNames(array $values) Set the custom values on the validator. | |
$this | addCustomValues(array $customValues) Add the custom values for the validator. | |
void | setFallbackMessages(array $messages) Set the fallback messages for the validator. | |
PresenceVerifierInterface | getPresenceVerifier() Get the Presence Verifier implementation. | |
void | setPresenceVerifier(PresenceVerifierInterface $presenceVerifier) Set the Presence Verifier implementation. | |
Translator | getTranslator() Get the Translator implementation. | |
void | setTranslator(Translator $translator) Set the Translator implementation. | |
void | setContainer(Container $container) Set the IoC container instance. | |
mixed | __call(string $method, array $parameters) Handle dynamic calls to class methods. |
Details
string makeReplacements(string $message, string $attribute, string $rule, array $parameters)
Replace all error message place-holders with actual values.
string getDisplayableAttribute(string $attribute)
Get the displayable name of the attribute.
string getDisplayableValue(string $attribute, mixed $value)
Get the displayable name of the value.
string guessColumnForQuery(string $attribute)
Guess the database column from the given attribute name.
bool isValidFileInstance(mixed $value)
Check that the given value is a valid file instance.
void __construct(Translator $translator, array $data, array $rules, array $messages = array(), array $customAttributes = array())
Create a new Validator instance.
array parseData(array $data)
Parse the data array, converting dots to ->.
$this after(callable|string $callback)
Add an after validation callback.
bool passes()
Determine if the data passes the validation rules.
bool fails()
Determine if the data fails the validation rules.
void validate()
Run the validator's rules against its data.
array valid()
Returns the data which was valid.
array invalid()
Returns the data which was invalid.
array failed()
Get the failed validation rules.
MessageBag messages()
Get the message container for the validator.
MessageBag errors()
An alternative more semantic shortcut to the message container.
MessageBag getMessageBag()
Get the messages for the instance.
bool hasRule(string $attribute, string|array $rules)
Determine if the given attribute has a rule in the given set.
array attributes()
Get the data under validation.
array getData()
Get the data under validation.
$this setData(array $data)
Set the data under validation.
array getRules()
Get the validation rules.
$this setRules(array $rules)
Set the validation rules.
void addRules(array $rules)
Parse the given rules and merge them into current rules.
$this sometimes(string $attribute, string|array $rules, callable $callback)
Add conditions to a given field based on a Closure.
void addExtensions(array $extensions)
Register an array of custom validator extensions.
void addImplicitExtensions(array $extensions)
Register an array of custom implicit validator extensions.
void addDependentExtensions(array $extensions)
Register an array of custom implicit validator extensions.
void addExtension(string $rule, Closure|string $extension)
Register a custom validator extension.
void addImplicitExtension(string $rule, Closure|string $extension)
Register a custom implicit validator extension.
void addDependentExtension(string $rule, Closure|string $extension)
Register a custom dependent validator extension.
void addReplacers(array $replacers)
Register an array of custom validator message replacers.
void addReplacer(string $rule, Closure|string $replacer)
Register a custom validator message replacer.
void setCustomMessages(array $messages)
Set the custom messages for the validator.
$this setAttributeNames(array $attributes)
Set the custom attributes on the validator.
$this addCustomAttributes(array $customAttributes)
Add custom attributes to the validator.
$this setValueNames(array $values)
Set the custom values on the validator.
$this addCustomValues(array $customValues)
Add the custom values for the validator.
void setFallbackMessages(array $messages)
Set the fallback messages for the validator.
PresenceVerifierInterface getPresenceVerifier()
Get the Presence Verifier implementation.
void setPresenceVerifier(PresenceVerifierInterface $presenceVerifier)
Set the Presence Verifier implementation.
Translator getTranslator()
Get the Translator implementation.
void setTranslator(Translator $translator)
Set the Translator implementation.
void setContainer(Container $container)
Set the IoC container instance.
mixed __call(string $method, array $parameters)
Handle dynamic calls to class methods.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.4/Illuminate/Validation/Validator.html