Question: Is it possible to validate a field only when it exists?

I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not displayed.

Answer: 
I saw another related answer here, maybe this is a valid solution too?

<https://github.com/jquense/yup/issues/1114>

Copying code from there:

```
const schema = yup.object({
    phone: yup.string().when('$exist', {
        is: exist => exist,
        then: yup.string().required(),
        otherwise: yup.string()
    })
})

```
this will help you

```
const schema = yup.object({
phone: yup.string().when('$exist', {
    is: exist => exist,
    then: yup.string().required(),
    otherwise: yup.string()
})

```

})