Skip to content

[Validator] AutoMapping Constrainst #34672

@mpiot

Description

@mpiot

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".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy