Final Class Yiisoft\Validator\Rule\StopOnErrorHandler
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
A handler for {@see StopOnError} rule. Validates a set of rules consecutively and stops at the rule where validation has failed.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| validate() | Yiisoft\ |
Method Details
| public Yiisoft\ | ||
| $value | mixed | |
| $rule | Yiisoft\ |
|
| $context | Yiisoft\ |
|
public function validate(mixed $value, RuleInterface $rule, ValidationContext $context): Result
{
if (!$rule instanceof StopOnError) {
throw new UnexpectedRuleException(StopOnError::class, $rule);
}
foreach ($rule->getRules() as $relatedRule) {
$result = $context->validate($value, $relatedRule);
if (!$result->isValid()) {
return $result;
}
}
return new Result();
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.