Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isDate validation is broken after upgrading to validator v13.11.0 #2256

Closed
tomaspanek opened this issue Aug 4, 2023 · 9 comments
Closed
Labels

Comments

@tomaspanek
Copy link
Contributor

tomaspanek commented Aug 4, 2023

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

@brunoabude
Copy link

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

return new Date(`${fullYear}-${dateObj.m}-${dateObj.d}`).getDate() === +dateObj.d;

@tomaspanek
Copy link
Contributor Author

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

@sacummings91
Copy link

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.

@gabdara
Copy link

gabdara commented Sep 18, 2023

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

@Achilles718611
Copy link

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

@brendengerber
Copy link

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

@ThiefMaster
Copy link

A bugfix release would be HIGHLY appreciated! :)

ThiefMaster added a commit to indico/redux-router-querystring that referenced this issue Apr 15, 2024
Date validation is brokein in certain circumstances and upstream has no
released a fix yet (validatorjs/validator.js#2256)
@WikiRik
Copy link
Member

WikiRik commented May 7, 2024

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

@profnandaa
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants