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()``::
117117 // ... 
118118 } 
119119
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; 
125122 } 
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(); 
126128 } 
127129 } 
128130
@@ -664,3 +666,4 @@ class to simplify writing unit tests for your custom constraints::
664666 // ... 
665667 } 
666668 } 
669+ 
                         You can’t perform that action at this time. 
           
                  
0 commit comments