-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Constraint validator "Symfony\Component\Validator\Constraints\RequiredValidator" does not exist or is not enabled #36723
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
Comments
I have the same on 4.4.8 |
Cannot reproduce this on 4.4.8 |
I have the same on 4.4.8 with |
Can anyone provide a small reproducer? For me this works fine on 4.4.8: <?php
require_once 'vendor/autoload.php';
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Required;
$kernel = new AppKernel('dev', true);
$kernel->boot();
$violations = $kernel->getContainer()->get('validator')->validate([[]], new All([
new Collection([
'email' => [
new NotBlank(),
new Email(),
],
'verified' => [
new Required(),
new Choice(['strict' => true, 'choices' => [1, 0, "1", "0", true, false]]),
],
]),
]));
dump($violations); |
<?php
require dirname(__DIR__).'/config/bootstrap.php';
use Symfony\Component\Validator\Constraints\Required;
$kernel = new \App\Kernel('dev', true);
$kernel->boot();
$violations = $kernel->getContainer()->get('validator')->validate(null, [
new Required(),
]);
dump($violations); In my case this prints for 4.4.8:
and for 4.4.7:
|
The best would be if one of you could provide a small example application allowing to reproduce the issue as suggested by @dmaicher. |
@xabbuh Here reproducer for a bug! Reproducer |
In my case the issue was reproduced on 4.4.8 the code created for symfony 3.3.36 and now updated to the 4.4.8. After this update I experienced the issue. Just for test I downgraded 4.4.8 -> 4.4.7 and could not reproduce the issue. After that I updated to 4.4.8 again. And everything works and the issue not reproduced |
@R11baka Thank you, I was able to reproduce. The behaviour changes is related to #36365. I don't know how we could achieve both (the solved issue and the way the constraint is used in the example). However, using the |
/cc @HeahDude |
@xabbuh I'm using the
Then require
Is this an unsupported use case for constraints? |
Basically yes, or to be more precise: Before the constraint placed in this way was just useless (i.e. there was no difference in having it or not). The |
@codegain I'm quite sure that your use case was actually to use |
@stof Currently I use the
I know there are other mechanisms like validation groups but that seemed to be the easiest option since |
see #36894 |
…tional) constraints (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [Validator] never directly validate Existence (Required/Optional) constraints | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #36637 #36723 | License | MIT | Doc PR | Using `Optional` or `Required` like "regular" constraints does not make any sense, but doing so didn't break before #36365. I suggest to ignore them for now and deprecate using them outside the `Collection` constraint in 5.2. Commits ------- d333aae never directly validate Existence (Required/Optional) constraints
Symfony version(s) affected: 3.4.40
3.4.39 is OK
Description
I get an error: Constraint validator "Symfony\Component\Validator\Constraints\RequiredValidator" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "Symfony\Component\Validator\Constraints\Required".
Line: 49
File: "/data/www/site/current/vendor/symfony/symfony/src/Symfony/Component/Validator/ContainerConstraintValidatorFactory.php"
How to reproduce
The text was updated successfully, but these errors were encountered: