surveyCategories
是一个既包含字符串又包含对象的数组。我只想使用Yup
验证此数组。验证条件在if条件下给出。
const surveyCategories = values.surveyCategories
.filter(value => !value.sub.subId)
.map(catId => value, 10);
const subCategories = values.surveyCategories
.filter(value => value.sub.subId)
.map(value => ({
id: value.sub.value,
intakeTypeId: value.sub.typeId,
intakeSubTypeId: value.sub.subId
}));
if (surveyCategories.includes(4) && !subCategories.length) {
console.log("Select atleast one intake to link with survey!");
}