Skip to content

Dependency Injection not more working for Validators #60611

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

Closed
ThomasTr opened this issue Jun 1, 2025 · 2 comments
Closed

Dependency Injection not more working for Validators #60611

ThomasTr opened this issue Jun 1, 2025 · 2 comments

Comments

@ThomasTr
Copy link
Contributor

ThomasTr commented Jun 1, 2025

Symfony version(s) affected

7.3.0

Description

Trying to upgrade to Version 7.3.0 and get the following error: "Too few arguments to function App\Validator\ProductValidator::__construct(), 0 passed in Projects/app/vendor/symfony/validator/ContainerConstraintValidatorFactory.php on line 49 and exactly 1 expected"

How to reproduce

My Constructor for my ProductValidator looks these:

    public function __construct(public EntityManagerInterface $entityManager)
    {
    }

The validator is called as assert via attributes in my DTO:

    #[AppAssert\Product]
    private array $productIds;

And validated here:

        /** @var T $dto */
        $dto        = $this->deserialize($this->extract($request), $type, $request);
        $violations = $this->validator->validate($dto);

Possible Solution

No response

Additional Context

In previous version this has worked. Has anything changed here?

@xabbuh
Copy link
Member

xabbuh commented Jun 1, 2025

Can you create a small example application that allows to reproduce your issue?

@ThomasTr
Copy link
Contributor Author

ThomasTr commented Jun 2, 2025

Had one #[\Attribute] too many in my validator service (also in the class that extends the ConstraintValidator). This does not seem to have been a problem in versions lower than 7.3, and has now led to this error when upgrading to 7.3.

@ThomasTr ThomasTr closed this as completed Jun 2, 2025
@xabbuh xabbuh closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants