Skip to content

[Validator] DateValidator, DateTimeValidator should accept \DateTimeInterface #42705

Closed
@dkarlovi

Description

@dkarlovi

Symfony version(s) affected: 5.3.6

Description
If passing a \DateTimeInterface value to DateValidator and DateTimeValidator, by default it treats it as invalid.

This is ironic since DateTimeValidator actually uses the fact an instance of \DateTime was successfully created as a signal the value is valid.

How to reproduce

Pass a valid instance of \DateTimeInterface to either DateValidator or \DateTimeValidator, they will validate it as invalid.

Possible Solution

Allow \DateTimeInterface values as valid.

Additional context

Using some tools to read Excel files already converts the values in cells to \DateTimeInterface instances (based on Excel cell value format hints). Passing the to the validation process fails it since it's not a string.

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