1 | <?php |
||
13 | class BaseRequest extends RequestObject implements ErrorResponseProvider |
||
14 | { |
||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | 7 | public function getErrorResponse(ConstraintViolationListInterface $errors) |
|
19 | { |
||
20 | 7 | return new JsonResponse([ |
|
21 | 7 | 'message' => 'Validation error. Please check your data.', //todo translate this message |
|
22 | 'errors' => array_map(function (ConstraintViolation $violation) { |
||
23 | // todo find the way to show correct path to property. |
||
24 | // Assert\* will return path like "[registration][username]" |
||
25 | // But UniqueEntity will return path like "username" |
||
26 | return [ |
||
27 | 7 | 'path' => $violation->getPropertyPath(), |
|
28 | 7 | 'message' => $violation->getMessage(), |
|
29 | ]; |
||
30 | 7 | }, iterator_to_array($errors)), |
|
31 | 7 | ], 400); |
|
32 | } |
||
33 | |||
34 | 11 | public function eachItemValidation(array $constraints) |
|
38 | } |
||
39 |