TLDR: how do I check that all 3 arrays are of the same length
I have an optional object people, and inside of which is an array person_name and each person has likes and dislikes. How can I check that:
if a person was entered at index 1 for example he must have an array at index 1 inside of likes and the same for dislikes?
for example this is accepted:
{
person_name: ['foo', 'bar'],
likes: [['foo stuff'], ['bar stuff']],
dislikes: [['bar'], ['foo']]
}
while these are not accepted:
{
person_name: ['foo', 'bar'],
likes: [['foo stuff'], ['bar stuff']],
dislikes: [['bar']]
}
AND
{
person_name: ['foo'],
likes: [['foo stuff'], ['bar stuff']],
dislikes: [['bar']]
}
this is an example of useFormik
const formik = useFormik({
initialValues: {
name: "",
description: "",
people: {
//each index in person_name maps to an array at the same index in likes and dislikes
person_name: [],
likes: [[]],
dislikes: [[]],
},
},...