Open
Description
Symfony version(s) affected
6.4
Description
#56962 appears to reference the same/similar issue however it's closed as completed. The validator does not collect any information about the #SerializedName, limiting the validator's usefulness when dealing with any kind of renamed fields.
How to reproduce
Essentially, if you had a property set up as such:
#[SerializedName('display_name')]
#[Assert\NotBlank()]
public string $displayName;
The validator, on failing, does not have any details that allow you to meaningfully respond to whatever "client" you might have. You'll get an error relating to displayName
and, whilst this is not incorrect, it's not hugely useful.
Generally speaking, the value specified in #[SerializedName]
is the external name. Perhaps the one relating to the API field, or the input field's name.
Possible Solution
Possible solutions:
- acknowledge the
SerializedName
by gathering it into another property, or perhaps: - provide a method for fetching an object that relates to the property - metadata or reflection instance or whatever - so that these things can be extracted.
Additional Context
No response