const validationSchema = Yup.lazy(values => {
switch (values.type) {
case '1':
return Yup.object().shape({
email: Yup.string().required('REQUIRED!!!'),
url: Yup.string().required('REQUIRED!!!')
});
case '2':
return Yup.object().shape({
name: Yup.object().shape({
x: Yup.string().required('REQUIRED!!!')
}
),
url: Yup.string().required('REQUIRED!!!')
});
default:
return mixed();
}
});
@js_ru
Обсуждают сегодня