sajad torkamani
const withoutEmailSchema = yup.object().shape({
  firstName: yup.string().required(),
  lastName: yup.string().required(),
})

const withEmailSchema = withoutEmailSchema.shape({
  email: yup.string().required().email(),
})

const validationSchema = someBoolCondition
  ? withoutEmailSchema
  : withEmailSchema

// Do something with the validationSchema (e.g., pass it to Formik)