if ($exception instanceof PartialDenormalizationException
) { $trans =
$this->translator ?
$this->translator->
trans(...
) :
fn ($m,
$p) =>
strtr($m,
$p);
$template = 'This value should be of type {{ type }}.';
$data =
[ self::TYPE => 'https://symfony.com/errors/validation',
self::TITLE => 'Validation Failed',
'violations' =>
array_map( fn ($e) =>
[ 'propertyPath' =>
$e->
getPath(),
'title' =>
$trans($template,
[ '{{ type }}' =>
implode('|',
$e->
getExpectedTypes() ??
['?'
]),
], 'validators'
),
'template' =>
$template,
'parameters' =>
[ '{{ type }}' =>
implode('|',
$e->
getExpectedTypes() ??
['?'
]),
],
] +
($debug ||
$e->
canUseMessageForUser() ?
['hint' =>
$e->
getMessage()] :
[]),
$exception->
getErrors() ),
];
$data['detail'
] =
implode("\n",
array_map(fn ($e) =>
$e['propertyPath'
].': '.
$e['title'
],
$data['violations'
]));
} elseif ($exception instanceof ValidationFailedException