我有一个电子邮件字段,只有在选中复选框时才会显示(布尔值为true)。当表单被提交时,如果复选框被选中(布尔值为真),我只需要这个字段。  
这是我迄今为止尝试过的:
    const validationSchema = yup.object().shape({
       email: yup
             .string()
             .email()
             .label('Email')
             .when('showEmail', {
                 is: true,
                 then: yup.string().required('Must enter email address'),
             }),
        })
我尝试了其他几种变体,但我从 Formik 和 Yup 那里得到错误:
Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
    at yupToFormErrors (formik.es6.js:6198)
    at formik.es6.js:5933
    at <anonymous>
yupToFormErrors @ formik.es6.js:6198
我也从 Yup 那里收到验证错误。我究竟做错了什么?