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 15
15
use Symfony \Component \Validator \Constraint ;
16
16
use Symfony \Component \Validator \ConstraintValidator ;
17
17
use Symfony \Component \Validator \Exception \LogicException ;
18
+ use Symfony \Component \Validator \Exception \UnexpectedTypeException ;
18
19
use Symfony \Component \Validator \Exception \UnexpectedValueException ;
19
20
20
21
/**
@@ -29,6 +30,10 @@ class BicValidator extends ConstraintValidator
29
30
*/
30
31
public function validate ($ value , Constraint $ constraint )
31
32
{
33
+ if (!$ constraint instanceof Bic) {
34
+ throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Bic ' );
35
+ }
36
+
32
37
if (null === $ value || '' === $ value ) {
33
38
return ;
34
39
}
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ class CountValidator extends ConstraintValidator
25
25
*/
26
26
public function validate ($ value , Constraint $ constraint )
27
27
{
28
+ if (!$ constraint instanceof Count) {
29
+ throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Count ' );
30
+ }
31
+
28
32
if (null === $ value ) {
29
33
return ;
30
34
}
Original file line number Diff line number Diff line change @@ -67,14 +67,14 @@ class UuidValidator extends ConstraintValidator
67
67
*/
68
68
public function validate ($ value , Constraint $ constraint )
69
69
{
70
- if (null === $ value || '' === $ value ) {
71
- return ;
72
- }
73
-
74
70
if (!$ constraint instanceof Uuid) {
75
71
throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Uuid ' );
76
72
}
77
73
74
+ if (null === $ value || '' === $ value ) {
75
+ return ;
76
+ }
77
+
78
78
if (!is_scalar ($ value ) && !(\is_object ($ value ) && method_exists ($ value , '__toString ' ))) {
79
79
throw new UnexpectedValueException ($ value , 'string ' );
80
80
}
You can’t perform that action at this time.
0 commit comments