Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validator] AutoMapping Constrainst #34672

Copy link
Copy link
Closed
@mpiot

Description

@mpiot
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.