I am using formik for form validation and came across some problems in array validation. here is my form structure
{
flow: [
{ text: "hello"
},
{ input: "world"
},
{ buttons: [
'hi',
'hello'
]
}
]
}
I have to create validation schema for this. So the array may contain any of these objects.
I tried this,
export const validationSchema = yup.object().shape({
flow: yup.array().of(
yup.mixed().oneOf([
{
text: yup.string().required('Enter text'),
},
{
buttons: yup.array().of(yup.string().required('Enter button title')),,
},
{
input: yup.string()
),
}
])
),
});
But am getting the following as formik error :
flow:[
"flow[0] must be one of the following values: [object Object], [object Object]",
"flow[1] must be one of the following values: [object Object], [object Object]"
]
How to solve this?