1

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!");
}
4

0 回答 0