perl-JSV icon indicating copy to clipboard operation
perl-JSV copied to clipboard

date format validation doesn't work for invalid date like 2017-02-29

Open takkyuuplayer opened this issue 7 years ago • 1 comments

Hi.

{type => 'string', format => 'date' } 

will pass validation for invalid date like 2017-02-29.

https://github.com/takkyuuplayer/perl-exercise/blob/master/t/jsv-validator.t#L222-L230

I think we should check date inside

https://github.com/zigorou/perl-JSV/blob/8e18e4a48eed3e4af4331961d18f8cd7c16cccd4/lib/JSV/Validator.pm#L70-L72

What do you think?

takkyuuplayer avatar Jan 20 '17 13:01 takkyuuplayer

FTR, Dates and Times in JSONSchema does cite RFC3339, which do state that the restrictions of date-mday (leap year) applies, but not necessarily for leap seconds (since one cannot reject a future time string that would turn out to be invalid due to the insertion/subtracting of leap seconds).

That means we can check for only leap years in this subroutine.

gugod avatar Sep 06 '18 08:09 gugod