Description
Symfony version(s) affected: 4.4.0
Description
When add the annotation @Assert\DisableAutoMapping()
, the Validator component try to find the DisableAutoMappingValidator
class, but it doesn't exists. Then you have a 500 error.
How to reproduce
In validator.yaml, under farmework -> validation, add:
#auto_mapping:
# App\Entity\: []
Then, in an entity add the special @Assert\DisableAutoMapping()
. On the next validation, the Validator try to find the DisableAutoMappingValidator
and fail.
Possible Solution
At the moment in my case, I've just create the Validator with a return in the validate method. Because, the Assert is not use as a Validator by the Validator component. But, this is apparently the Bridge/Doctrine/Validator/DoctrineLoader
that take care of this annotations.
<?php
namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
class DisableAutoMappingValidator extends ConstraintValidator
{
public function validate($value, Constraint $constraint)
{
return;
}
}
But there is maybe a better solution ? Else, I've a PR (https://github.com/mpiot/symfony/tree/auto_mapping)
Additional context
Constraint validator "Symfony\Component\Validator\Constraints\DisableAutoMappingValidator" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "Symfony\Component\Validator\Constraints\DisableAutoMapping".