File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1515use Symfony \Component \Validator \Constraint ;
1616use Symfony \Component \Validator \ConstraintValidator ;
1717use Symfony \Component \Validator \Exception \LogicException ;
18+ use Symfony \Component \Validator \Exception \UnexpectedTypeException ;
1819use Symfony \Component \Validator \Exception \UnexpectedValueException ;
1920
2021/**
@@ -29,6 +30,10 @@ class BicValidator extends ConstraintValidator
2930 */
3031 public function validate ($ value , Constraint $ constraint )
3132 {
33+ if (!$ constraint instanceof Bic) {
34+ throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Bic ' );
35+ }
36+
3237 if (null === $ value || '' === $ value ) {
3338 return ;
3439 }
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ class CountValidator extends ConstraintValidator
2525 */
2626 public function validate ($ value , Constraint $ constraint )
2727 {
28+ if (!$ constraint instanceof Count) {
29+ throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Count ' );
30+ }
31+
2832 if (null === $ value ) {
2933 return ;
3034 }
Original file line number Diff line number Diff line change @@ -67,14 +67,14 @@ class UuidValidator extends ConstraintValidator
6767 */
6868 public function validate ($ value , Constraint $ constraint )
6969 {
70- if (null === $ value || '' === $ value ) {
71- return ;
72- }
73-
7470 if (!$ constraint instanceof Uuid) {
7571 throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Uuid ' );
7672 }
7773
74+ if (null === $ value || '' === $ value ) {
75+ return ;
76+ }
77+
7878 if (!is_scalar ($ value ) && !(\is_object ($ value ) && method_exists ($ value , '__toString ' ))) {
7979 throw new UnexpectedValueException ($ value , 'string ' );
8080 }
You can’t perform that action at this time.
0 commit comments