Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UniqueEntityValidator in 7.1 no longer works with private properties #57255

@ostrolucky

Description

@ostrolucky

Symfony version(s) affected

7.1

Description

I've just upgraded symfony/validator to 7.1 and now we get this kind of error

{"@context":"\/api\/contexts\/Error","@type":"hydra:Error","hydra:title":"An error occurred","hydra:description":"Property Proxies\\__CG__\\App\\Entity\\Company::$name does not exist","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"\/Users\/gostrolucky\/Documents\/eqs\/data-center-api\/vendor\/symfony\/doctrine-bridge\/Validator\/Constraints\/UniqueEntityValidator.php","line":298,"args":[]},{"namespace":"","short_class":"ReflectionProperty","class":"ReflectionProperty","type":"-\u003E","function":"__construct","file":"\/Users\/gostrolucky\/Documents\/eqs\/data-center-api\/vendor\/symfony\/doctrine-bridge\/Validator\/Constraints\/UniqueEntityValidator.php","line":298,"args":[["string","Proxies\\__CG__\\App\\Entity\\Company"],["string","name"]]},{"namespace":"Symfony\\Bridge\\Doctrine\\Validator\\Constraints","short_class":"UniqueEntityValidator","class":"Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator","type":"-\u003E","fu..

How to reproduce

#[UniqueEntity(fields: ['name'], message: 'already.exist', errorPath: '', ignoreNull: false)]
class Company {
  public string $name;

  public function getName(): string
    {
        return $this->name;
    }
}

Possible Solution

No response

Additional Context

No response

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