Skip to content

[HttpKernel] Add customization options to #[MapQueryString] and #[MapRequestPayload] #18344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,16 @@ attribute in your controller::
// ...
}

You can customize the validation groups used during the mapping thanks to the
``validationGroups`` option::

public function dashboard(
#[MapQueryString(validationGroups: ['strict', 'edit'])] UserDTO $userDto
): Response
{
// ...
}

.. versionadded:: 6.3

The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString` attribute
Expand Down Expand Up @@ -482,6 +492,16 @@ your DTO::
// ...
}

You can also customize the validation groups used as well as supported
payload formats::

public function dashboard(
#[MapRequestPayload(acceptFormat: 'json', validationGroups: ['strict', 'read'])] UserDTO $userDto
): Response
{
// ...
}

.. versionadded:: 6.3

The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapRequestPayload` attribute
Expand Down