Validation
trait Validation
Properties
protected MessageBag | $validationErrors | Error messages as provided by the validator. |
|
protected array | $validationDefaultAttrNames | ||
protected bool | $validating | Whether the model should undergo validation when saving or not. |
|
protected Factory | $validator | The Validator factory class used for validation. |
Methods
Boot the trait. Adds an observer class for validating.
Returns whether or not the model will attempt to validate itself when saving.
Set whether the model should attempt validation on saving.
Get the casted model attributes.
Get the custom validation messages being used by the model.
Get the custom validation attribute names being used by the model.
Get the Validator instance.
No description
Get the global validation rules.
Get the validation error messages from the model.
Set the error messages.
Throw a validation exception.
Returns whether the model will raise an exception or return a boolean when validating.
Returns whether or not the model will add it's unique identifier to the rules when validating.
Set the model to add unique identifier to rules when performing validation.
Perform validation with the specified ruleset.
No description
Fire the namespaced validating event.
Fire the namespaced post-validation event.
If the model already exists and it has unique validations it is going to fail validation unless we also pass it's primary key to the rule so that it may be ignored.
Get the dynamic method name for a unique identifier injector rule if it exists, otherwise return false.
Rebuilds the unique validation rule to force for the existing ID
Details
at line 50
static void
bootValidation()
Boot the trait. Adds an observer class for validating.
at line 76
bool
getValidating()
Returns whether or not the model will attempt to validate itself when saving.
at line 87
void
setValidating(bool $value)
Set whether the model should attempt validation on saving.
at line 97
array
getValidationAttributes()
Get the casted model attributes.
at line 107
array
getValidationMessages()
Get the custom validation messages being used by the model.
at line 117
array
getValidationAttributeNames()
Get the custom validation attribute names being used by the model.
at line 127
Factory
getValidator()
Get the Validator instance.
at line 132
validate()
No description
at line 148
array
getRules()
Get the global validation rules.
at line 158
MessageBag
getErrors()
Get the validation error messages from the model.
at line 169
void
setErrors(MessageBag $validationErrors)
Set the error messages.
at line 179
throwValidationException()
Throw a validation exception.
at line 192
bool
getThrowValidationExceptions()
Returns whether the model will raise an exception or return a boolean when validating.
at line 203
bool
getInjectUniqueIdentifier()
Returns whether or not the model will add it's unique identifier to the rules when validating.
at line 216
void
setInjectUniqueIdentifier(bool $value)
Set the model to add unique identifier to rules when performing validation.
at line 227
protected bool
performValidation(string $event)
Perform validation with the specified ruleset.
at line 258
protected
makeValidator($rules = [])
No description
at line 284
protected mixed
fireValidatingEvents(string $event)
Fire the namespaced validating event.
at line 303
protected void
fireValidatedEvents(string $status)
Fire the namespaced post-validation event.
at line 320
protected array
injectUniqueIdentifierToRules(array $rules)
If the model already exists and it has unique validations it is going to fail validation unless we also pass it's primary key to the rule so that it may be ignored.
This will go through all the rules and append the model's primary key to the unique rules so that the validation will work as expected.
at line 361
protected mixed
getUniqueIdentifierInjectorMethod(string $validationRule)
Get the dynamic method name for a unique identifier injector rule if it exists, otherwise return false.
at line 374
protected string
processValidationUniqueRule(string $definition, string $fieldName)
Rebuilds the unique validation rule to force for the existing ID