Skip to content

[Validator] Improve documentation for UniqueEntity constraint #21197

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

Open
wants to merge 3 commits into
base: 7.3
Choose a base branch
from

Conversation

ker0x
Copy link
Contributor

@ker0x ker0x commented Jul 9, 2025

Replace #14458 and #20166

I'm targeting 7.3 because i don't know if changes made in 7.1 are transferred to 7.3. Otherwise, let me know and I'll change it.

@ker0x ker0x requested a review from xabbuh as a code owner July 9, 2025 12:19
@carsonbot carsonbot changed the title [DoctrineBridge][Validator] Improve documentation for UniqueEntity constraint [Validator] Improve documentation for UniqueEntity constraint Jul 9, 2025
@ker0x ker0x force-pushed the fix/unique-entity branch 2 times, most recently from 604f8fe to b1a3e1a Compare July 9, 2025 12:24
@OskarStark OskarStark changed the title [Validator] Improve documentation for UniqueEntity constraint [Validator] Improve documentation for UniqueEntity constraint Jul 9, 2025
@ker0x ker0x force-pushed the fix/unique-entity branch from b1a3e1a to 7f65194 Compare July 9, 2025 15:48
@wkania
Copy link
Contributor

wkania commented Aug 1, 2025

Nice. Looking at my pull request, I think it would also be helpful to mention which version of Symfony introduced this feature.

.. versionadded:: 7.1
    Any class instance (like DTO) field (or fields) validation against entities persisted in the database was introduced in Symfony 7.1.

.. versionadded:: 7.1

    The option was introduced in Symfony 7.1.

``identifierFieldNames``
~~~~~~~~~~~~~~~~~~~~~~~~

**type**: ``array`` **default**: ``[]``
Copy link
Contributor

@wkania wkania Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type should be **type**: ``array`` | ``string`` [:ref:`default option <validation-default-option>`]
It accept string when not combined identifier. Like:
identifierFieldNames: 'id'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so because the property is typed with ?array in the UniqueEntity class: https://github.com/symfony/doctrine-bridge/blob/7.3/Validator/Constraints/UniqueEntity.php#L60

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, I see that in the end I didn't do it like fields argument.

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