File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
src/Symfony/Component/Validator/Constraints Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Validator \Constraint ;
15
15
use Symfony \Component \Validator \ConstraintValidator ;
16
+ use Symfony \Component \Validator \Exception \UnexpectedTypeException ;
16
17
17
18
/**
18
19
* @author Michael Hirschler <michael.vhirsch@gmail.com>
@@ -26,6 +27,10 @@ class BicValidator extends ConstraintValidator
26
27
*/
27
28
public function validate ($ value , Constraint $ constraint )
28
29
{
30
+ if (!$ constraint instanceof Bic) {
31
+ throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Bic ' );
32
+ }
33
+
29
34
if (null === $ value || '' === $ value ) {
30
35
return ;
31
36
}
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 @@ -66,14 +66,14 @@ class UuidValidator extends ConstraintValidator
66
66
*/
67
67
public function validate ($ value , Constraint $ constraint )
68
68
{
69
- if (null === $ value || '' === $ value ) {
70
- return ;
71
- }
72
-
73
69
if (!$ constraint instanceof Uuid) {
74
70
throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Uuid ' );
75
71
}
76
72
73
+ if (null === $ value || '' === $ value ) {
74
+ return ;
75
+ }
76
+
77
77
if (!is_scalar ($ value ) && !(\is_object ($ value ) && method_exists ($ value , '__toString ' ))) {
78
78
throw new UnexpectedTypeException ($ value , 'string ' );
79
79
}
You can’t perform that action at this time.
0 commit comments