0 follower

Final Class Yiisoft\Validator\EmptyCondition\WhenMissing

InheritanceYiisoft\Validator\EmptyCondition\WhenMissing

Empty condition is a callable returning true if a value must be considered empty.

With WhenMissing a rule is considered empty only when the value is missing. With regard to validation process, a corresponding rule is skipped only if this condition is met and WhenMissing is set:

  • At a rule level via $skipOnEmpty property, but only for rules implementing {@see \Yiisoft\Validator\EmptyCondition\SkipOnEmptyTrait} / including {@see \Yiisoft\Validator\EmptyCondition\SkipOnEmptyTrait}.
  • At validator level ({@see \Yiisoft\Validator\EmptyCondition\Validator::$defaultSkipOnEmptyCondition}).

There is no shortcut for this condition, because it's considered less used. Use new instance directly: new WhenMissing().

Method Details

Hide inherited methods

__invoke() public method

public boolean __invoke ( mixed $value, boolean $isPropertyMissing false )
$value mixed

The validated value.

$isPropertyMissing boolean

A flag defining whether the property is missing (not used / not passed at all).

return boolean

Whether the validated value is considered empty.

                public function __invoke(mixed $value, bool $isPropertyMissing = false): bool
{
    return $isPropertyMissing;
}