Interface Yiisoft\Validator\SkipOnEmptyInterface
An optional interface for rules to implement. It allows skipping validation for a rule when the validated value is "empty".
The package ships with Yiisoft\Validator\Rule\Trait\SkipOnEmptyTrait which already implements that interface. All you have to do is include it in the rule class along with the interface.
Psalm Types
| Name | Value |
|---|---|
| SkipOnEmptyCallable | callable |
| SkipOnEmptyValue | \Yiisoft\Validator\SkipOnEmptyCallable|boolean|null |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getSkipOnEmpty() | Returns current "skip on empty" value. | Yiisoft\Validator\SkipOnEmptyInterface |
| skipOnEmpty() | Changes current "skip on empty" value. Must be immutable. | Yiisoft\Validator\SkipOnEmptyInterface |
Method Details
Returns current "skip on empty" value.
During pre-validation phase it will be normalized to an "empty condition" - a callable identifying when and which values exactly must be considered as empty for corresponding rules to be skipped or not skipped at all.
| public abstract getSkipOnEmpty( ): boolean|callable|null | ||
| return | boolean|callable|null |
A raw non-normalized value:
Examples of custom callables with built-in condition:
A custom callable for skipping only when a value is zero:
An equivalent class implementing
|
|---|---|---|
public function getSkipOnEmpty(): bool|callable|null;
Signup or Login in order to comment.