\Omega\Validation AbstractValidation

Abstract validation defines the contract for adding and validating rules.

The AbstractValidation provides methods for adding validation rules and validating data against those rules.

Summary

Methods
Properties
Constants
addRule
validate
No public properties found
No public constants found
No protected methods found
rules
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$rules

$rules : array

Rule array.

Type

array<string, RuleInterface> — Holds an array of rules.

Methods

addRule()

addRule(string  $alias, \Omega\Validation\Rule\RuleInterface  $rule) : $this

Add a validation rule to the validator.

Parameters

string $alias

Holds the alias for the rule.

\Omega\Validation\Rule\RuleInterface $rule

Holds an instance of RuleInterface representing the rule.

Returns

$this —

validate()

validate(array  $data, array>  $rules, string  $sessionName = 'errors') : array<string,mixed>

Validate data against a set of rules.

Parameters

array $data

Holds an array of data to validate.

array> $rules

Holds an array of validation rules.

string $sessionName

Holds the session name for storing validation errors.

Throws

\Omega\Validation\Exception\ValidationException

if validation fails.

Returns

array

Return an array containing valid data.