validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

`isDate` validation is broken after upgrading to validator v13.11.0

Open tomaspanek opened this issue 1 year ago • 6 comments

Describe the bug

After upgrading to version 13.11.0, the validation of date strings stopped working as expected.

Examples

Here is a demonstration that compares the validation results between v13.11.0 and v13.9.0 Issue demonstration

Additional context Validator.js version: 13.11.0 Node.js version: 18.17.0 OS platform: macOS

tomaspanek avatar Aug 04 '23 22:08 tomaspanek

Looks like the Date constructor is now using the ISO8601 date format without the time zone offset info, which causes it to be interpreted as UTC+0 and can fail the comparison of .getDate() and the parsed day from the date string (which could be safely assumed to be in local time, i guess?)

To keep the same behaviour as the previous version, T00:00:00 could be concatenated to the isoformat, which will cause it to be interpreted as local time. As demonstrated here

https://github.com/validatorjs/validator.js/blob/f074abdd851d56c8425bc14aec41049eb26b041e/src/lib/isDate.js#L68

brunoabude avatar Aug 05 '23 02:08 brunoabude

Thanks, @brunoabude! Just submitted a pull request that would solve the timezone issues as you suggested.

tomaspanek avatar Aug 05 '23 03:08 tomaspanek

Can confirm this was breaking for us too. It was tricky to debug cuz it worked in our CI just fine but was failing locally. Rolling back to 13.9.0 for now to solve the issue until the fix goes in.

sacummings91 avatar Aug 10 '23 17:08 sacummings91

I have the same problem on macOS, seems to work on other platforms though. reverted to 13.9.0 for now.

gabdara avatar Sep 18 '23 12:09 gabdara

When are we going to have next release? Due to this issue, I can't use the latest version.

Achilles718611 avatar Feb 01 '24 16:02 Achilles718611

@Achilles718611 Also wondering this, I just downgraded to 13.9.0 and everything is working for me in the meantime

brendengerber avatar Feb 14 '24 20:02 brendengerber

A bugfix release would be HIGHLY appreciated! :)

ThiefMaster avatar Apr 14 '24 08:04 ThiefMaster

This should be fixed in v13.12.0 which will be released after #2269 is merged

WikiRik avatar May 07 '24 20:05 WikiRik

Now released - https://www.npmjs.com/package/validator/v/13.12.0

profnandaa avatar May 09 '24 05:05 profnandaa