Skip to content

Commit 7fb2843

Browse files
authored
refactoring IsTrueValidator
1 parent bd1e4ac commit 7fb2843

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Constraints/IsTrueValidator.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ public function validate(mixed $value, Constraint $constraint)
2929
throw new UnexpectedTypeException($constraint, IsTrue::class);
3030
}
3131

32-
if (null === $value) {
32+
if (null === $value || true === $value || 1 === $value || '1' === $value) {
3333
return;
3434
}
3535

36-
if (true !== $value && 1 !== $value && '1' !== $value) {
37-
$this->context->buildViolation($constraint->message)
38-
->setParameter('{{ value }}', $this->formatValue($value))
39-
->setCode(IsTrue::NOT_TRUE_ERROR)
40-
->addViolation();
41-
}
36+
$this->context->buildViolation($constraint->message)
37+
->setParameter('{{ value }}', $this->formatValue($value))
38+
->setCode(IsTrue::NOT_TRUE_ERROR)
39+
->addViolation();
4240
}
4341
}

0 commit comments

Comments
 (0)