Skip to content

Form: Using Optional constraint triggers ClassNotFoundException #11013

Closed
@cjunge-work

Description

@cjunge-work

To get an entity's fields to show correctly in the NelmioApiDoc output I added @Assert\Optional() constraint to the phpdoc, and now I get a ClassNotFoundException.

It seems the ConstraintValidatorFactory is trying to load a OptionalValidator class to handle the Optional constraint. I assume the same issue would occur with the Required constraint as the RequiredValidator is also missing.

I'm using Symfony 2.4.5.

I may be using the constraint incorrectly?

ClassNotFoundException: Attempted to load class "OptionalValidator" from namespace "Symfony\Component\Validator\Constraints" in /var/www/server/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Validator/ConstraintValidatorFactory.php line 71. Do you need to "use" it from another namespace?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions