const schema = yup.object().shape({
fields: yup.object().shape({
email: yup.mixed().when('fields', {
is: (fields: {email?: string | null}) => {
console.log(fields);
return false;
},
then: yup.string().email('Not valid email'),
otherwise: yup.string().notRequired(),
}),
}),
})