Protected properties

protected Illuminate\Support\MessageBag $validationErrors

The message bag instance containing validation error messages

protected static Illuminate\Validation\Validator $validator

The validator instance.

Public methods

public static void bootValidation()

Boot the validation trait for this model.

public Illuminate\Support\MessageBag errors()

Get validation error message collection for the Model

public bool forceSave($options=NULL)

Force save the model even if validation fails.

  • $options

public static Illuminate\Validation\Validator getModelValidator()

Get the validator instance.

public boolean isAttributeRequired(string $attribute)

Determines if an attribute is required based on the validation rules.

  • string $attribute

public static void setModelValidator(Illuminate\Validation\Validator $validator)

Set the validator instance.

  • Illuminate\Validation\Validator $validator

public static void unsetModelValidator()

Unset the validator for models.

public bool validate($rules=NULL, $customMessages=NULL, $attributeNames=NULL)

Validate the model instance

  • $rules
  • $customMessages
  • $attributeNames

public static void validated(Closure|string $callback)

Create a new native event for handling afterValidate().

  • Closure|string $callback

public static void validating(Closure|string $callback)

Create a new native event for handling beforeValidate().

  • Closure|string $callback

Protected methods

protected array getValidationAttributes()

Returns the model data used for validation.

protected static Illuminate\Validation\Validator makeValidator($data, $rules, $customMessages, $attributeNames)

Instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel.

  • $data
  • $rules
  • $customMessages
  • $attributeNames

protected array processRuleFieldNames(array $rules)

Processes field names in a rule array.

Converts any field names using array notation (ie. field[child]) into dot notation (ie. field.child)

  • array $rules - Rules array

protected void processValidationRules($rules)

Process rules

  • $rules