Error validation not working with Formik and Yup
See original GitHub issueEnvironment
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
- A form using formik with an InlineDatePicker and formik configured for Yup schema validation.
- 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())),
- 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:
- Created 5 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
I also want to set the validation if the endDate is less than StartDate. I am using KeyboardDatePicker from material-ui pickers.