Skip to content

Commit d9aae0b

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: hint for mapping request payload error messages
2 parents 419f5d7 + f205e2c commit d9aae0b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

controller.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,16 @@ the validation fails as well as supported payload formats::
523523
// ...
524524
}
525525

526-
527526
The default status code returned if the validation fails is 422.
528527

528+
.. tip::
529+
530+
If you build a JSON API, make sure to declare your route as using the JSON
531+
:ref:`format <routing-format-parameter>`. This will make the error handling
532+
output a JSON response in case of validation errors, rather than an HTML page::
533+
534+
#[Route('/dashboard', name: 'dashboard', format: 'json')]
535+
529536
Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_
530537
if you want to map a nested array of specific DTOs::
531538

0 commit comments

Comments
 (0)