I have two arrays and I want at least one of them to be filled before submitting
My config:
initialValues={{
images: [],
current_images: [],
}}
validationSchema={Yup.object().shape(
{
images: Yup.array().when("current_images", {
is: (current_images) => current_images.length === 0,
then: Yup.array().min(1, "Pick at least one image"),
otherwise: Yup.array(),
}),
current_images: Yup.array().when("images", {
is: (images) => images.length === 0,
then: Yup.array().min(1, "Pick at least one image"),
otherwise: Yup.array(),
}),
},
[["current_images", "images"]]
)}
Version:
"formik": "^2.2.9",
"yup": "^0.32.11"
Here is the error I got after clicking submit button:

How can I fix this problem ?