File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -121,12 +121,14 @@ The validator class only has one required method ``validate()``::
121121 // ...
122122 }
123123
124- if (!preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
125- // the argument must be a string or an object implementing __toString()
126- $this->context->buildViolation($constraint->message)
127- ->setParameter('{{ string }}', $value)
128- ->addViolation();
124+ if (preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
125+ return;
129126 }
127+
128+ // the argument must be a string or an object implementing __toString()
129+ $this->context->buildViolation($constraint->message)
130+ ->setParameter('{{ string }}', $value)
131+ ->addViolation();
130132 }
131133 }
132134
@@ -547,3 +549,4 @@ class to simplify writing unit tests for your custom constraints::
547549 // ...
548550 }
549551 }
552+
You can’t perform that action at this time.
0 commit comments