@@ -44,6 +44,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
44
44
}
45
45
46
46
$ operation = $ request ->attributes ->get ('_api_operation ' ) ?? $ operation ;
47
+ $ constraintViolationList = new ConstraintViolationList ();
47
48
foreach ($ operation ->getParameters () ?? [] as $ parameter ) {
48
49
if (!$ constraints = $ parameter ->getConstraints ()) {
49
50
continue ;
@@ -52,28 +53,27 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
52
53
$ key = $ this ->getParameterFlattenKey ($ parameter ->getKey (), $ this ->extractParameterValues ($ parameter , $ request , $ context ));
53
54
$ value = $ parameter ->getExtraProperties ()['_api_values ' ][$ key ] ?? null ;
54
55
$ violations = $ this ->validator ->validate ($ value , $ constraints );
55
- if (0 !== \count ($ violations )) {
56
- $ constraintViolationList = new ConstraintViolationList ();
57
- foreach ($ violations as $ violation ) {
58
- $ propertyPath = $ key !== $ parameter ->getKey () ? $ key .$ violation ->getPropertyPath () : ($ parameter ->getProperty () ?? $ key );
59
- $ constraintViolationList ->add (new ConstraintViolation (
60
- $ violation ->getMessage (),
61
- $ violation ->getMessageTemplate (),
62
- $ violation ->getParameters (),
63
- $ violation ->getRoot (),
64
- $ propertyPath ,
65
- $ violation ->getInvalidValue (),
66
- $ violation ->getPlural (),
67
- $ violation ->getCode (),
68
- $ violation ->getConstraint (),
69
- $ violation ->getCause ()
70
- ));
71
- }
72
-
73
- throw new ValidationException ($ constraintViolationList );
56
+ foreach ($ violations as $ violation ) {
57
+ $ propertyPath = $ key !== $ parameter ->getKey () ? $ key .$ violation ->getPropertyPath () : ($ parameter ->getProperty () ?? $ key );
58
+ $ constraintViolationList ->add (new ConstraintViolation (
59
+ $ violation ->getMessage (),
60
+ $ violation ->getMessageTemplate (),
61
+ $ violation ->getParameters (),
62
+ $ violation ->getRoot (),
63
+ $ propertyPath ,
64
+ $ violation ->getInvalidValue (),
65
+ $ violation ->getPlural (),
66
+ $ violation ->getCode (),
67
+ $ violation ->getConstraint (),
68
+ $ violation ->getCause ()
69
+ ));
74
70
}
75
71
}
76
72
73
+ if (0 !== \count ($ constraintViolationList )) {
74
+ throw new ValidationException ($ constraintViolationList );
75
+ }
76
+
77
77
return $ this ->decorated ->provide ($ operation , $ uriVariables , $ context );
78
78
}
79
79
}
0 commit comments