Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Yup惰性选项调用的验证类型错误_Reactjs_Typescript_Yup_Typescript Types - Fatal编程技术网

Reactjs Yup惰性选项调用的验证类型错误

Reactjs Yup惰性选项调用的验证类型错误,reactjs,typescript,yup,typescript-types,Reactjs,Typescript,Yup,Typescript Types,我们已经有一段时间出现这种类型的错误,我不知道如何修复它,我尝试了很多方法,快速修复也无法修复它。当我传入项和选项时,yup.lazy的yup验证模式在typescript中显示一个类型错误,我不知道如何修复它。如何为此传递适当的yup.StringSchema 这是我的密码: export const schema = yup.object().shape({ contactID: yup.string().required('Please select an option').nulla

我们已经有一段时间出现这种类型的错误,我不知道如何修复它,我尝试了很多方法,快速修复也无法修复它。当我传入项和选项时,yup.lazy的yup验证模式在typescript中显示一个类型错误,我不知道如何修复它。如何为此传递适当的yup.StringSchema

这是我的密码:

export const schema = yup.object().shape({
  contactID: yup.string().required('Please select an option').nullable(),
  firstName: yup.string().when('contactID', {
    is: 'other',
    then: yup.string().required('First Name is required').nullable(),
    otherwise: yup.string().nullable(),
  }),
  lastName: yup.string().when('contactID', {
    is: 'other',
    then: yup.string().required('Last Name is required').nullable(),
    otherwise: yup.string().nullable(),
  }),
  insuredName: yup.string().nullable(),
  phoneNumber: personaSchemaSwitch({
    is: (value: any) => makePersonaCheck(value, [CustomerTypes.SaAgent]),
    then: phoneValidation(true),
    otherwise: phoneValidation(true).required('Phone Number is required'),
  }),
  phoneNumbers: yup.array().of(
    yup.object().shape({
      phoneNumber: yup.lazy((item: any, options: any) => {
        if (options.path === 'insuredContactInformation.phoneNumbers[0].phoneNumber') {
          return phoneValidation(true).required('Phone Number is required');
        } else {
          return phoneValidation(true).nullable();
        }
      }),
      phoneType: yup.lazy((item: any, options: any) => {
        if (options.parent.phoneNumber !== '') {
          return yup.string().required('Phone Type is required');
        } else {
          return yup.string().nullable();
        }
      }),
    })
  ),
  phoneType: yup.string().nullable(),
  email: emailValidation(true).nullable(),
  relationshipToInsured: yup.string().nullable(),
});
下面是显示的错误: