Conditional Validation in Yup
问题 I have an email field that only gets shown if a checkbox is selected (boolean value is true ). When the form get submitted, I only what this field to be required if the checkbox is checked (boolean is true). This is what I've tried so far: const validationSchema = yup.object().shape({ email: yup .string() .email() .label('Email') .when('showEmail', { is: true, then: yup.string().required('Must enter email address'), }), }) I've tried several other variations, but I get errors from Formik and