Skip to content
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

Add UniqueEntity constraint field validation #556

Open
VincentLanglet opened this issue Mar 27, 2024 · 0 comments
Open

Add UniqueEntity constraint field validation #556

VincentLanglet opened this issue Mar 27, 2024 · 0 comments

Comments

@VincentLanglet
Copy link
Contributor

Symfony provides a UniqueEntity annotation
https://symfony.com/doc/current/reference/constraints/UniqueEntity.html

The first arguments need to be entity fields, which will be use by a findBy call (by default).
So a rule could be implemented, similar to

class RepositoryMethodCallRule implements Rule

in order to check that all field names passed exist.

The repository method can be overriden in the constraint to use something else than findBy,
as a first step we could ignore constraint with an overridden method.

@ondrejmirtes I know it's a Symfony constraint, but since it requires objectManagerLoader to have class metadata I think it's more an issue for phpstan-doctrine or phpstan-symfony.

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

No branches or pull requests

1 participant