Skip to content

Commit d262c2c

Browse files
committed
bug #376 [make:validator] Custom constraints should ignore null and empty values (voronkovich)
This PR was squashed before being merged into the 1.0-dev branch (closes #376). Discussion ---------- [make:validator] Custom constraints should ignore null and empty values See https://symfony.com/doc/current/validation/custom_constraint.html#creating-the-validator-itself Commits ------- c959791 [make:validator] Custom constraints should ignore null and empty values
2 parents d5d142e + c959791 commit d262c2c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Resources/skeleton/validator/Validator.tpl.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public function validate($value, Constraint $constraint)
1111
{
1212
/* @var $constraint \<?= $constraint_class_name ?> */
1313

14+
if (null === $value || '' === $value) {
15+
return;
16+
}
17+
18+
// TODO: implement the validation here
1419
$this->context->buildViolation($constraint->message)
1520
->setParameter('{{ value }}', $value)
1621
->addViolation();

0 commit comments

Comments
 (0)