0 follower

Interface Yiisoft\Validator\ValidatorInterface

Implemented byYiisoft\Validator\Debug\ValidatorInterfaceProxy, Yiisoft\Validator\Validator

An interface allowing to validate the data according to the set of rules (Yiisoft\Validator\RuleInterface) and validation context (Yiisoft\Validator\ValidationContext). A class implementing it is called "validator".

Public Methods

Hide inherited methods

Method Description Defined By
validate() Validates the data according to the set of rules (Yiisoft\Validator\RuleInterface) and validation context (Yiisoft\Validator\ValidationContext). Yiisoft\Validator\ValidatorInterface

Method Details

Hide inherited methods

validate() public abstract method

Validates the data according to the set of rules (Yiisoft\Validator\RuleInterface) and validation context (Yiisoft\Validator\ValidationContext).

public abstract validate( Yiisoft\Validator\DataSetInterface|mixed|Yiisoft\Validator\RulesProviderInterface $data, callable|iterable|object|string|null $rules null, Yiisoft\Validator\ValidationContext|null $context null ): Yiisoft\Validator\Result
$data Yiisoft\Validator\DataSetInterface|mixed|Yiisoft\Validator\RulesProviderInterface

Data to validate:

$rules callable|iterable|object|string|null

Rules to apply for validating data. If specified, this argument has higher priority over Yiisoft\Validator\RulesProviderInterface::getRules() provided in $data argument. A variety of types is supported. They are normalized before usage, please refer to Yiisoft\Validator\Helper\RulesNormalizer documentation to see what structures can be passed.

$context Yiisoft\Validator\ValidationContext|null

Validation context that may be taken into account when performing validation.

return Yiisoft\Validator\Result

The result of validation.

throws ReflectionException

If an object / \Yiisoft\Validator\ObjectDataSet providing rules or (and) data used in $data argument and there was a Reflection error during parsing them.

                public function validate(
    mixed $data,
    callable|iterable|object|string|null $rules = null,
    ?ValidationContext $context = null,
): Result;