October\Rain\Halcyon\Traits\Validation

Overview


Protected Properties

protected Illuminate\Support\MessageBag $validationErrors

validationErrors message bag

protected static Illuminate\Validation\Validator $validator

validator instance


Public Methods

public static bootValidation()

public static bootValidation(): void

bootValidation trait for this model.

public errors()

public errors(): Illuminate\Support\MessageBag 

errors gets validation error message collection for the Model

public forceSave()

public forceSave($options = null): bool 

forceSave the model even if validation fails.

public static getModelValidator()

public static getModelValidator(): Illuminate\Validation\Validator 

getModelValidator instance.

public isAttributeRequired()

public isAttributeRequired(string $attribute): bool 

isAttributeRequired determines if an attribute is required based on the validation rules.

public static setModelValidator()

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

setModelValidator instance.

public static unsetModelValidator()

public static unsetModelValidator(): void 

unsetModelValidator for models.

public validate()

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

validate the model instance

public static validated()

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

validated creates a new native event for handling afterValidate().

public static validating()

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

validating creates a new native event for handling beforeValidate().

Protected Methods

protected getValidationAttributes()

protected getValidationAttributes(): array 

getValidationAttributes returns the model data used for validation.

protected static makeValidator()

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

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

protected processRuleFieldNames()

protected processRuleFieldNames(array $rules): array 

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

protected processValidationRules()

protected processValidationRules($rules): void