File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,19 @@ characters long::
53
53
}
54
54
}
55
55
56
- The validator returns the list of violations.
56
+ The ``validate() `` method returns the list of violations as an object that
57
+ implements :class: `Symfony\\ Component\\ Validator\\ ConstraintViolationListInterface `.
58
+ If you have lots of validation errors, you can filter them by error code::
59
+
60
+ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
61
+
62
+ $violations = $validator->validate(...);
63
+ if (count($violations->findByCodes(UniqueEntity::NOT_UNIQUE_ERROR))) {
64
+ // handle this specific error (display some message, send an email, etc.)
65
+ }
66
+
67
+ .. versionadded :: 3.3
68
+ The ``findByCodes() `` method was introduced in Symfony 3.3.
57
69
58
70
Retrieving a Validator Instance
59
71
-------------------------------
You can’t perform that action at this time.
0 commit comments