出现这个错误的原因是因为在使用yup.lazy()方法时,没有正确地传递参数value。根据您的代码,应该将value作为参数传递给yup.lazy()方法。

您可以尝试以下更正:

anytimeReceptionEndDateTime: deadline === '2'
    ?  yup.lazy((value) =>
      value
        ? yup
          .string()
          // .test('isDateTime', validationMessageSet.datetime, (value: any) => miscRegexSet.datetime1.test(value))
          : yup.string()
          .required(validationMessageSet.required)
    )
    : yup.string()
      .notRequired(),

在这里,我们将value作为参数传递给yup.lazy()方法,并将括号放在正确的位置。

请注意,如果您在其他地方使用了类似的代码,也需要确保正确地传递value参数

determineDateTime deadline === 0 yupstring requiredvalidationMessageSetrequired yupstring notRequiredanytimeReceptionEndDateTime deadline === 2 yuplazyvalue = value

原文地址: https://www.cveoy.top/t/topic/irw3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录