Final Class Yiisoft\Validator\Helper\SkipOnEmptyNormalizer
| Inheritance | Yiisoft\Validator\Helper\SkipOnEmptyNormalizer |
|---|
A helper class used to normalize different types of "skip on empty" values including shortcuts to a callable (Yiisoft\Validator\SkipOnEmptyInterface).
Public Methods
| Method | Description | Defined By |
|---|---|---|
| normalize() | Normalizes different types of "skip on empty" values including shortcuts to a callable: | Yiisoft\Validator\Helper\SkipOnEmptyNormalizer |
Method Details
Normalizes different types of "skip on empty" values including shortcuts to a callable:
nullandfalsevalues are normalized to Yiisoft\Validator\EmptyCondition\NeverEmpty.truevalue is normalized to Yiisoft\Validator\EmptyCondition\WhenEmpty.- A callable is left as is.
- Other types are rejected causing the exception.
| public static normalize( boolean|callable|null $skipOnEmpty ): callable | ||
| $skipOnEmpty | boolean|callable|null |
Raw "skip on empty" value of any type. |
| return | callable |
An empty condition as a callable. |
|---|---|---|
public static function normalize(bool|callable|null $skipOnEmpty): callable
{
if ($skipOnEmpty === false || $skipOnEmpty === null) {
return new NeverEmpty();
}
if ($skipOnEmpty === true) {
return new WhenEmpty();
}
return $skipOnEmpty;
}
Signup or Login in order to comment.