Closed
Description
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