Skip to content

[Validator] Choice constraint callback does not accepts array anymore #19313

Closed
@symfonyaml

Description

@symfonyaml

Hi,

Forgive me if I'm wrong.

  • Docs : The documentation about the Choice#callback constraint says that the available types are string|array|Closure.
  • Code : The Choice class constructor only accepts callable|string now since Symfony version 6.x.

Basically the doc says we can do this :

#[Assert\Choice(callback: [Genre::class, 'getGenres'])]
protected string $genre;

which throws the following error

TypeError: Symfony\Component\Validator\Constraints\Choice::__construct():
Argument #3 ($callback) must be of type callable|string|null, array given

Metadata

Metadata

Assignees

No one assigned

    Labels

    ValidatorbughasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions