zigorou / perl-JSV

JSON Schema implementation for Perl
Other
25 stars 17 forks source link

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

Open takkyuuplayer opened 7 years ago

takkyuuplayer commented 7 years ago

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?

gugod commented 6 years ago

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.