question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error validation not working with Formik and Yup

See original GitHub issue

Environment

Tech Version
material-ui-pickers 2.2.1
material-ui 3.9.2
React 16.8.1
Browser Chrome 71
Peer library date-fns(date-io): 1.1.0
Formik 1.5.0
Yup 0.26.10

Steps to reproduce

  1. A form using formik with an InlineDatePicker and formik configured for Yup schema validation.
  2. The shema of validation validates some stuffs on the fields of InlineDatePicker. Here as schema definition for those files:
startDate: Yup.date().required(),
  endDate: Yup.date().when('startDate', (startDate, schema) => (startDate ? schema.min(startDate) : schema.date())),
  1. There is no errors at all that appears. If I remove those two schema validation, it works perfectly.

Expected behavior

The picker does not block schema validation.

Actual behavior

Schema validation is no more working for any field on the schema.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
maxmann74commented, Mar 4, 2020

I am having this issue as well. The “Invalid Date” error shows up, but when I clear the value, the “Required” error never shows up.

6reactions
nilamsavani91commented, Nov 18, 2019

I’m also trying to figure out how to use yup with the date-picker.

I also want to set the validation if the endDate is less than StartDate. I am using KeyboardDatePicker from material-ui pickers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formik & yup form validation not working as expected with ...
My component is working and I am able to select an option, but why formik together with 'yup' validation showing me an error...
Read more >
Validation
Formik is designed to manage forms with complex validation with ease. Formik supports synchronous and asynchronous form-level and field-level validation.
Read more >
React Formik and Yup Troubleshooting Tips
Issue: If your form is pre-populated with data and validation doesn't work on component mount. Ensure you've set validateOnMount={true} within your Formik ......
Read more >
Easy Error Handling and Data Validation with Yup - Code Daily
Introduction. Formik has first class support for yup . It's a declarative way to handle both synchronous and asynchronous error handling.
Read more >
Error validation not working with Formik and Yup · Issue #919
A form using formik with an InlineDatePicker and formik configured for Yup schema validation. The shema of validation validates some stuffs on ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found