0 follower

Final Class Yiisoft\Validator\Helper\RulesNormalizerIterator

InheritanceYiisoft\Validator\Helper\RulesNormalizerIterator
ImplementsIteratorAggregate

An iterator for a set of rules, performs normalization for every individual rule unifying other provided types and verifying that every item is a valid rule instance. It also applies some default settings if needed.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( iterable $rules, callable|null $defaultSkipOnEmptyCondition null )
$rules iterable

A rules' iterable for checking and normalization.

$defaultSkipOnEmptyCondition callable|null

A default "skip on empty" condition ({@see \Yiisoft\Validator\SkipOnEmptyInterface}), already normalized. Used to optimize setting the same value in all the rules. Defaults to null meaning that it's not used.

                public function __construct(
    private readonly iterable $rules,
    ?callable $defaultSkipOnEmptyCondition = null,
) {
    $this->defaultSkipOnEmptyCondition = $defaultSkipOnEmptyCondition;
}

            
getIterator() public method

public Traversable getIterator ( )

                public function getIterator(): Traversable
{
    foreach ($this->rules as $rule) {
        yield self::normalizeRule($rule, $this->defaultSkipOnEmptyCondition);
    }
}