Skip to content

[Validator] [UniqueValidator] Use correct variable as parameter in (custom) error message #57213

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 1 commit into from
Jun 9, 2024

Conversation

seho-nl
Copy link
Contributor

@seho-nl seho-nl commented May 28, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues
License MIT

Unique constraint should use the $element (the element violating uniqueness) and not $values (the collection) to build the error message.

When adding a custom message to the Constraint, for example
message: 'Duplicate element found with value {{ value }}'
It outputs:
Duplicate element found with value "array"
And the expected output should be:
Duplicate element found with value "main" (where main is an example value in the collection).

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "5.4" but it seems your PR description refers to branch "5.4, 6.4, 7.0, and 7.1".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@OskarStark OskarStark changed the title [Validator] [UniqueValidator] Use correct variable as parameter in (custom) error message. [Validator] [UniqueValidator] Use correct variable as parameter in (custom) error message May 29, 2024
@OskarStark OskarStark changed the title [Validator] [UniqueValidator] Use correct variable as parameter in (custom) error message [Validator][UniqueValidator] Use correct variable as parameter in (custom) error message May 30, 2024
@carsonbot carsonbot changed the title [Validator][UniqueValidator] Use correct variable as parameter in (custom) error message [Validator] [UniqueValidator] Use correct variable as parameter in (custom) error message Jun 9, 2024
@fabpot fabpot force-pushed the seho-nl-patch-uniquevalidator branch from dd6e5f7 to 8ef75c2 Compare June 9, 2024 07:03
@fabpot
Copy link
Member

fabpot commented Jun 9, 2024

Thank you @seho-nl.

@fabpot fabpot merged commit 82bb267 into symfony:5.4 Jun 9, 2024
10 of 12 checks passed
@xabbuh xabbuh mentioned this pull request Jun 22, 2024
xabbuh added a commit that referenced this pull request Jun 22, 2024
This PR was merged into the 6.4 branch.

Discussion
----------

[Validator]  fix test

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

update test after merging #57213 up

Commits
-------

f2883ba fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants