You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
isISO8601 accepts impossible calendar dates (2021-02-30, 2021-04-31, 2021-02-29 in a non-leap year) #2940
isISO8601 checks the date components with a regex, so it rejects impossible months (00, 13) and day 00, but it does not verify that the day exists in the given month/year. Calendar-invalid dates pass:
constvalidator=require("validator");// 13.15.35validator.isISO8601("2021-02-30");// => true (Feb has 28/29 days)validator.isISO8601("2021-04-31");// => true (Apr has 30 days)validator.isISO8601("2021-02-29");// => true (2021 is not a leap year)validator.isISO8601("2021-13-01");// => false (month 13 correctly rejected)validator.isISO8601("2021-00-10");// => falsevalidator.isISO8601("2021-02-00");// => false
ISO 8601 calendar dates are defined as valid Gregorian dates, so a 2021-02-30 is not a valid ISO 8601 date, and isISO8601 returning true for it makes the validator unreliable as a gate before parsing.
Note: #2841 covers the same problem for isRFC3339; this report is specifically about isISO8601, which still accepts these dates in 13.15.35.
Expected behavior
isISO8601("2021-02-30"), isISO8601("2021-04-31") and isISO8601("2021-02-29") (non-leap year) should return false.
Withdrawn - my report is wrong. The README documents strict: false (the default) as syntax-only validation, and strict: true correctly rejects every example I gave:
Activity
philppplik commentedon Oct 22, 2026
Withdrawn - my report is wrong. The README documents
strict: false(the default) as syntax-only validation, andstrict: truecorrectly rejects every example I gave:So the behavior I described is the documented default mode, not a bug. Apologies for the noise - please feel free to close this.