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

Error on invalid dates #214

Merged
merged 4 commits into from
Oct 20, 2023
Merged

Error on invalid dates #214

merged 4 commits into from
Oct 20, 2023

Conversation

sillvva
Copy link
Contributor

@sillvva sillvva commented Oct 17, 2023

One thing missing from the date and dateAsync schemas is Invalid Date handling. With new Date("Not a date") you get Invalid Date, but dateObj instanceof Date returns true.

This is similar to the NaN issue, which is already handled by the number schema.

A fix for this is to test whether dateObj.getTime() returns NaN.

Playground Demo: https://playcode.io/1631384

@netlify
Copy link

netlify bot commented Oct 17, 2023

Deploy Preview for valibot canceled.

Name Link
🔨 Latest commit 407c03d
🔍 Latest deploy log https://app.netlify.com/sites/valibot/deploys/6531d31696db88000829f895

@fabian-hiller
Copy link
Owner

Thank you for noticing this issue!

@fabian-hiller fabian-hiller self-assigned this Oct 17, 2023
@fabian-hiller fabian-hiller added bug Something isn't working priority This has priority labels Oct 17, 2023
@fabian-hiller fabian-hiller merged commit 1f213ec into fabian-hiller:main Oct 20, 2023
4 checks passed
@fabian-hiller
Copy link
Owner

v0.20.0 is now available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority This has priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants