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

date().required("Required") #601

Closed
donadley opened this issue Aug 15, 2019 · 2 comments
Closed

date().required("Required") #601

donadley opened this issue Aug 15, 2019 · 2 comments

Comments

@donadley
Copy link

When adding a string parameter to required() ex. 'required("Required")' for yup.date the parameter is not added to the validation object when validate() is ran.

expected: Required
actual: effectiveDate must be a date type, but the final value was: Invalid Date (cast from the value "").

Yup Object used

export const = DateSchema = Yup.object().shape({
  date : Yup.object().shape({
    effectiveDate: Yup.date().required("Required"),
    expirationDate: Yup.string().required('Required'),
  })
})

Also expirationDate's error message in the validation object shows "Requred" as expected.

@donadley
Copy link
Author

donadley commented Aug 15, 2019

The issue is resolved. I needed to add .nullable().

Yup.date().required("Required").nullable().

@Vages
Copy link

Vages commented Feb 9, 2021

I think I just spent 6 hours of my workday walking in circles around the problem described in this issue and this issue: #851 😅

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

No branches or pull requests

2 participants