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 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 @@ -26,6 +26,10 @@ class CountValidator extends ConstraintValidator
26
26
*/
27
27
public function validate ($ value , Constraint $ constraint )
28
28
{
29
+ if (!$ constraint instanceof Count) {
30
+ throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Count ' );
31
+ }
32
+
29
33
if (null === $ value ) {
30
34
return ;
31
35
}
Original file line number Diff line number Diff line change @@ -83,14 +83,14 @@ class UuidValidator extends ConstraintValidator
83
83
*/
84
84
public function validate ($ value , Constraint $ constraint )
85
85
{
86
- if (null === $ value || '' === $ value ) {
87
- return ;
88
- }
89
-
90
86
if (!$ constraint instanceof Uuid) {
91
87
throw new UnexpectedTypeException ($ constraint , __NAMESPACE__ .'\Uuid ' );
92
88
}
93
89
90
+ if (null === $ value || '' === $ value ) {
91
+ return ;
92
+ }
93
+
94
94
if (!is_scalar ($ value ) && !(\is_object ($ value ) && method_exists ($ value , '__toString ' ))) {
95
95
throw new UnexpectedTypeException ($ value , 'string ' );
96
96
}
You can’t perform that action at this time.
0 commit comments