Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpKernel] Hardcoded validation translation domain on RequestPayloadValueResolver #58170

Copy link
Copy link
Closed
@raphael-drdata

Description

@raphael-drdata
Issue body actions

Symfony version(s) affected

6.3

Description

In \Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestPayloadValueResolver::140 during the payload denormalization we map PartialDenormalizationException's errors into ConstraintViolations and we translate the messages with an hardcoded validators domain.

So it does not take into account the possible override in framework.validation.

PS : I'll be glad to make the PR once the way to correct this is decided

How to reproduce

Override the translation_domain in framework.validation with a custom one and override the translations:

  • This value was of an unexpected type
  • This value should be of type {{ type }}

Create a controller with a MapRequestPayload Dto parameter and send a request with a wrongly typed property (send a string to a bool property for example). The violation message will not take your override message template into account.

Possible Solution

Do we really need to translate the message here ?
Can we pass the validator.translation_domain param into this service (Not the same component) ?

Additional Context

$trans = $this->translator ? $this->translator->trans(...) : fn ($m, $p) => strtr($m, $p);
 [...]
$message = $trans($template, $parameters, 'validators');
$violations->add(new ConstraintViolation($message, $template, $parameters, null, $error->getPath(), null));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.