It would be very useful to be able to check if a string is a valid date. It is a very common use case to get a date string from a form or from an external service.
Example from moment.js: moment('29.2.2013', 'DD.MM.YYYY').isValid()
Code which I believe moment.js uses for this:
https://github.com/moment/moment/blob/c587bf0063c18214238ca83f3f9c6170daf25bed/src/lib/create/from-string.js
A PR for that would be much appreciated @loota !
Respect\Validation also validates this:
use Respect\Validation\Validator as v;
var_dump(
v::date('d.m.Y')->validate('30.6.2015'), //true
v::date('d.m.Y')->validate('31.6.2015'), //false
v::date('d.m.Y')->validate('29.2.2015'), //false
v::date('d.m.Y')->validate('29.2.2016') //true
);
?>
The code seems to be here: https://github.com/Respect/Validation/blob/master/library/Rules/Date.php
Feel free to open a PR @loota
shame
Most helpful comment
Feel free to open a PR @loota