\Omega\Validation ValidationInterface

Validation interface defines the contract for adding and validating rules.

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

Summary

Methods
Constants
addRule()
validate()
No public constants found

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.