Validation

 trait Winter\Storm\Database\Traits\Validation

Properties

protected $validationDefaultAttrNames : array

Default custom attribute names.

protected $validationErrors : Illuminate\Support\MessageBag

The message bag instance containing validation error messages

Methods

public static bootValidation () : void

Boot the validation trait for this model.

Returns
void

public errors () : Illuminate\Support\MessageBag

Get validation error message collection for the Model

Returns
Illuminate\Support\MessageBag

public forceSave ($options = null, $sessionKey = null) : bool

Force save the model even if validation fails.

Parameters
Property Description
$options
mixed
$sessionKey
mixed
Returns
bool

public isAttributeRequired (string $attribute, boolean $checkDependencies = true) : bool

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

Parameters
Property Description
$attribute
string
$checkDependencies
boolean

Checks the attribute dependencies (for required_if & required_with rules). Note that it will only be checked up to the next level, if another dependent rule is found then it will just assume the field is required

Returns
bool

public setValidationAttributeName (string $attr, string $name) : void

Programatically sets the validation attribute names, will take lower priority to model defined attribute names found in $attributeNames.

Parameters
Property Description
$attr
string
$name
string
Returns
void

public setValidationAttributeNames (array $attributeNames) : void

Programatically sets multiple validation attribute names.

Parameters
Property Description
$attributeNames
array
Returns
void

public validate ($rules = null, $customMessages = null, $attributeNames = null) : bool

Validate the model instance

Parameters
Property Description
$rules
mixed
$customMessages
mixed
$attributeNames
mixed
Returns
bool

public static validated (Closure | string $callback) : void

Create a new native event for handling afterValidate().

Parameters
Property Description
$callback
Closure | string
Returns
void

public static validating (Closure | string $callback) : void

Create a new native event for handling beforeValidate().

Parameters
Property Description
$callback
Closure | string
Returns
void

protected getRelationValidationValue ($relationName)

Attachments validate differently to their simple values.

Parameters
Property Description
$relationName
mixed
Returns
mixed

protected getValidationAttributes () : array

Returns the model data used for validation.

Returns
array

protected static makeValidator ($data, $rules, $customMessages, $attributeNames, $connection = null) : Illuminate\Contracts\Validation\Validator

Instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel. Optional connection string to make the validator use a different database connection than the default connection.

Parameters
Property Description
$data
mixed
$rules
mixed
$customMessages
mixed
$attributeNames
mixed
$connection
mixed
Returns
Illuminate\Contracts\Validation\Validator

protected processRuleFieldNames (array $rules) : array

Processes field names in a rule array.

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

Parameters
Property Description
$rules
array

Rules array

Returns
array

protected processValidationRules ($rules)

Process rules

Parameters
Property Description
$rules
mixed
Returns
mixed

protected processValidationUniqueRule (string $definition, string $fieldName) : string

Rebuilds the unique validation rule to force for the existing ID

Parameters
Property Description
$definition
string
$fieldName
string
Returns
string

Used by

Class Description
LogSetting

System log settings

MailBrandSetting

Mail brand settings

MailLayout

Mail layout

MailPartial

Mail partial

MailSetting

Mail settings

MailTemplate

Mail template

BrandSetting

Brand settings that affect all users

EditorSetting

Editor settings that affect all users

ImportModel

Model used for importing data

Preference

Backend preferences for the backend user

User

Administrator user model

UserGroup

Administrator group

UserRole

Administrator role

MaintenanceSetting

Maintenance mode settings

ThemeData

Customization data used by a theme

ThemeExport

Theme export model

ThemeImport

Theme import model

Group

Group model

Role

Role model

User

User model

Copyright © 2024 Winter CMS