Formik: Is there a way to pass props to validationSchema => for dynamic validation

Created on 28 Jul 2017  路  1Comment  路  Source: formium/formik

Something like:

  validationSchema: props => {
    const schema = {};

    props.answers.forEach(answer => {
      schema[answer.id] = Yup.string().required('Required');
    });

    return Yup.object().shape(schema);
  },
Medium Question

Most helpful comment

Weirdly @jaredpalmer and I were just talking about this literally five minutes before you posted, and we are probably going to add this feature today.

>All comments

Weirdly @jaredpalmer and I were just talking about this literally five minutes before you posted, and we are probably going to add this feature today.

Was this page helpful?
0 / 5 - 0 ratings