mirror of
https://github.com/Respect/Validation.git
synced 2024-06-07 16:22:16 +02:00
Update the validation engine of the "When" rule
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
2c56575ce3
commit
d184d9d95b
|
@ -19,7 +19,7 @@ use Respect\Validation\Validatable;
|
|||
'after asserting that',
|
||||
'after failing to assert that',
|
||||
)]
|
||||
final class When extends AbstractRule
|
||||
final class When extends Standard
|
||||
{
|
||||
use CanBindEvaluateRule;
|
||||
|
||||
|
@ -53,35 +53,4 @@ final class When extends AbstractRule
|
|||
|
||||
return $elseResult->withNextSibling($thisResult->withNextSibling($whenResult));
|
||||
}
|
||||
|
||||
public function validate(mixed $input): bool
|
||||
{
|
||||
if ($this->when->validate($input)) {
|
||||
return $this->then->validate($input);
|
||||
}
|
||||
|
||||
return $this->else->validate($input);
|
||||
}
|
||||
|
||||
public function assert(mixed $input): void
|
||||
{
|
||||
if ($this->when->validate($input)) {
|
||||
$this->then->assert($input);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->else->assert($input);
|
||||
}
|
||||
|
||||
public function check(mixed $input): void
|
||||
{
|
||||
if ($this->when->validate($input)) {
|
||||
$this->then->check($input);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->else->check($input);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue