Closed
Description
Symfony version(s) affected
7.2.0
Description
In #57436 a change was introduced that affects the behavior of the Unique constraint. Specifically, a line was added in UniqueValidator:
->atPath("[$index]" . (null !== $constraint->errorPath ? ".{$constraint->errorPath}" : ''))
This change now adds [$index] to every propertyPath, even when errorPath isn't set. This alters the previous behavior and might cause issues, especially in existing implementations where the index wasn't part of the path.
It would be great if this change could be made optional or if the old behavior could be kept to avoid breaking compatibility with older code.
How to reproduce
Compare the propertyPath
for an array field with a Unique constraint in Symfony 7.1 (which should be just the property name, e.g., propertyName
) and Symfony 7.2.0 (where it includes the index, e.g., propertyName[$index]
).
Possible Solution
No response
Additional Context
No response