I make a stepper formik form and the objective is yup should validate each step of the form. this is my validation schema:
const schema = [
yup
.object()
.shape({
field1: yup.string().required("cannot be empty"),
field2: yup.string().required("cannot be empty"),
}),
yup
.object()
.shape({
field3: yup.string().required("cannot be empty"),
field4: yup.string().required("cannot be empty"),
}),
yup
.object()
.shape({
field5: yup.string().required("cannot be empty"),
field6: yup.string().required("cannot be empty"),
}),
];
<Formik
initialValues={initialValues}
validationSchema={schema}
onSubmit={_handleSubmit}
>
{({ isSubmitting, dirty, isValid, values, resetForm }) => (
<Form>// ........ rest of the code</Form>
)}
</Formik>
but i got error massage “schema[(intermediate value)(intermediate value)(intermediate value)] is not a function”. how should i setting up he validation schema?