Interface Yiisoft\Validator\WhenInterface
An optional interface for rules to implement. It allows applying validation for a rule within a group of other rules under certain conditions.
The package ships with \Yiisoft\Validator\WhenTrait which already implements that interface. All you have to do is include it in the rule class along with the interface.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getWhen() | Returns current "when" value. | Yiisoft\Validator\WhenInterface |
| when() | Changes current "when" value. Must be immutable. | Yiisoft\Validator\WhenInterface |
Method Details
Returns current "when" value.
| public abstract getWhen( ): Closure|null |
public function getWhen(): ?Closure;
Changes current "when" value. Must be immutable.
See also Yiisoft\Validator\ValidationContext for publicly available methods and properties for building condition.
| public abstract when( Closure|null $value ): $this | ||
| $value | Closure|null | |
| return | $this |
The new instance of a rule with a changed value. |
|---|---|---|
public function when(?Closure $value): static;
Signup or Login in order to comment.