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 @@ -117,12 +117,14 @@ The validator class only has one required method ``validate()``::
117
117
// ...
118
118
}
119
119
120
- if (!preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
121
- // the argument must be a string or an object implementing __toString()
122
- $this->context->buildViolation($constraint->message)
123
- ->setParameter('{{ string }}', $value)
124
- ->addViolation();
120
+ if (preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
121
+ return;
125
122
}
123
+
124
+ // the argument must be a string or an object implementing __toString()
125
+ $this->context->buildViolation($constraint->message)
126
+ ->setParameter('{{ string }}', $value)
127
+ ->addViolation();
126
128
}
127
129
}
128
130
@@ -664,3 +666,4 @@ class to simplify writing unit tests for your custom constraints::
664
666
// ...
665
667
}
666
668
}
669
+
You can’t perform that action at this time.
0 commit comments