Reactjs Yup惰性选项调用的验证类型错误
我们已经有一段时间出现这种类型的错误,我不知道如何修复它,我尝试了很多方法,快速修复也无法修复它。当我传入项和选项时,yup.lazy的yup验证模式在typescript中显示一个类型错误,我不知道如何修复它。如何为此传递适当的yup.StringSchema 这是我的密码: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
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(),
});
下面是显示的错误: