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

Fix date parsing to match docs and support timestamps #2057

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pgjones
Copy link

@pgjones pgjones commented Jul 12, 2023

The yup documentation states

The default cast logic of date is pass the value to the Date
constructor, failing that, it will attempt to parse the date as an
ISO date string.

which wasn't true and would manifest for timestamps i.e.

const schema = yup.date();
schema.validateSync(1411500325000) // Failed to validate

as the cast logic would try Date.parse(1411500325000) which would return an invalid date.

The yup documentation states

    The default cast logic of date is pass the value to the Date
    constructor, failing that, it will attempt to parse the date as an
    ISO date string.

which wasn't true and would manifest for timestamps i.e.

    const schema = yup.date();
    schema.validateSync(1411500325000) // Failed to validated

as the cast logic would try Date.parse(1411500325000) which would
return an invalid date.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant