validator.js
validator.js copied to clipboard
isISO8601 returns true for an invalid iso8601 date
Describe the bug When using isISO8601 to check date that looks like iso8601 format, but missing seconds, will return true even though it is an invalid date
Examples Date string such as "2018-09-11T10:16.000Z" will return true. Live sample: https://codesandbox.io/s/wandering-fire-qr6fm6?file=/src/index.js
Additional context Validator.js version: 13.7.0 Node.js version: 16 OS platform: macOS
@rubiin Can I work on this issue?
@sahilsuman933 sure jump ahead. Before you do, read the contribution guidelines though
@rubiin Sure.
@rubiin I was validating the test cases for the iso8601, and many of them are incorrectly placed.
For example, 2009-222 is not a valid ISO8601 date but is put in the validISO8601.
Also, there is no need for isValidDate function cause there we can already use the inbuilt !isNaN(Date.parse) method to validate whether it is a valid date. One more thing, I think there is no need for a strict separator.
So I was thinking of re-writing the whole new ISO8601 code. So can I go ahead and do it?
Sure. As long as the tests are properly written and the logic defines the code