Skip to content

[Form] Explain deprecation of @Assert\Date on DateTimeInterface fields #13998

@ThomasLandauer

Description

@ThomasLandauer

symfony/symfony#25015 gives this deprecation note:

DEPRECATION: Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Date" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface.

This fact should be explained at the corresponding Constraint pages, e.g. https://symfony.com/doc/current/reference/constraints/Date.html

Question: If you just rely on the ?\DateTimeInterface type-hint of the setter, and the user submits an invalid date in a form, how can you show a nice error message? What's the best practice here?

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