\Omega\Validation Validation

Validation manager class.

The ValidationManager class provides a flexible and extensible way to perform data validation. This class allows you to define validation rules and validate 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.