Material-ui-pickers: Error validation not working with Formik and Yup

Created on 12 Feb 2019  路  5Comments  路  Source: mui-org/material-ui-pickers

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.

Most helpful comment

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.

All 5 comments

We know that - in v3 (#862) we will definitely recreate for integration process. Possibly duplicate of #836.

@dmtrKovalenko are you able to please provide an example of how to do this properly now?

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

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brett-patterson picture brett-patterson  路  3Comments

filipenevola picture filipenevola  路  4Comments

danmce picture danmce  路  3Comments

dandv picture dandv  路  3Comments

sakulstra picture sakulstra  路  3Comments