Search code examples
reactjsformikyupredux-orm

Formik & ReduxORM & Yup - validationSchema issue


I'm trying to use a Formik form with a Yup validation schema to edit an entity which come from my ReduxORM session. The validation does not seem to work properly when using a ReduxORM model.

I think it's a Formik issue because I succeed to validate properly my entity using the validate function to manually call Yup:

validate={values => CompanyFormSchema.validate(values, { abortEarly: false }).catch(errors => { throw yupToFormErrors(errors) })}

(see codesandbox below to try both methods)

Here's a codesendbox which reproduce the issue: https://codesandbox.io/s/formik-reduxorm-validationschema-issue-kd95s

I expect the validationSchema attribute to work with ReduxORM model. Have you an idea of what I'm doing wrong ?


Solution

  • Solution provide by Christiann (in comment section) is working: "You need to extract the fields from the entity: let initialValues = entity._fields;"

    Did someone know why there is a difference beetween the schemaValidation behaviour of Formik and the fact to call manually Yup validation schema ?