File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -430,6 +430,16 @@ attribute in your controller::
430
430
// ...
431
431
}
432
432
433
+ You can customize the validation groups used during the mapping thanks to the
434
+ ``validationGroups `` option::
435
+
436
+ public function dashboard(
437
+ #[MapQueryString(validationGroups: ['strict', 'edit'])] UserDTO $userDto
438
+ ): Response
439
+ {
440
+ // ...
441
+ }
442
+
433
443
.. versionadded :: 6.3
434
444
435
445
The :class: `Symfony\\ Component\\ HttpKernel\\ Attribute\\ MapQueryString ` attribute
@@ -482,6 +492,16 @@ your DTO::
482
492
// ...
483
493
}
484
494
495
+ You can also customize the validation groups used as well as supported
496
+ payload formats::
497
+
498
+ public function dashboard(
499
+ #[MapRequestPayload(acceptFormat: 'json', validationGroups: ['strict', 'read'])] UserDTO $userDto
500
+ ): Response
501
+ {
502
+ // ...
503
+ }
504
+
485
505
.. versionadded :: 6.3
486
506
487
507
The :class: `Symfony\\ Component\\ HttpKernel\\ Attribute\\ MapRequestPayload ` attribute
Original file line number Diff line number Diff line change @@ -114,10 +114,12 @@ store the HTTP status code and message respectively.
114
114
and its required ``getStatusCode() `` method. Otherwise, the ``status_code ``
115
115
will default to ``500 ``.
116
116
117
- Additionally you have access to the Exception with ``exception ``, which for example
118
- allows you to output the stack trace using ``{{ exception.traceAsString }} `` or
119
- access any other method on the object. You should be careful with this though,
120
- as this is very likely to expose sensitive data.
117
+ Additionally you have access to the :class: `Symfony\\ Component\\ HttpKernel\\ Exception\\ HttpException `
118
+ object via the ``exception `` Twig variable. For example, if the exception sets a
119
+ message (e.g. using ``throw $this->createNotFoundException('The product does not exist') ``),
120
+ use ``{{ exception.message }} `` to print that message. You can also output the
121
+ stack trace using ``{{ exception.traceAsString }} ``, but don't do that for end
122
+ users because the trace contains sensitive data.
121
123
122
124
.. tip ::
123
125
You can’t perform that action at this time.
0 commit comments