0👍
Add memberType
to the validation then you can do something like this:
const validationSchema = Yup.object().shape({
memberType: Yup.string().required(),
phone: Yup
.string()
.trim()
.label("Phone")
.when("memberType", {
is: "individual",
then: Yup.string().required("Must enter phone number")
}),
tax: Yup
.string()
.trim()
.label("Tax")
.when("memberType", {
is: "corporate",
then: Yup.string().required("Must enter tax number")
}),
});
Source:stackexchange.com