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

Skip to content

[Validator] Deprecate Date and Time constraints, replace with DateTime #28173

Closed
@ostrolucky

Description

@ostrolucky

Since #17553 DateTimeValidator has format option, which should cover all needs.

Other mentioned validators are very unflexible. For instance, we wanted to validate date is in d/m/Y format and found we could not use DateValidator for this, because there is no way to change the order of regex matches passed to checkdate().

Assuming upgrade path in user space is following

Date() -> DateTime(['format' => 'Y-m-d'])
Time() -> DateTime(['format' => 'H:i:s'])

This should also cover a need of failing validation when value passed in contains extra characters, same as current solution with regex:

>>> DateTime::createFromFormat('Y-m-d', '2018-08-08 20:00:00')
=> false
>>> DateTime::createFromFormat('Y-m-d H:i:s', '2018-08-08')
=> false

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