title: Cyclic Dependency in Formik Yup Schema
body: <p>I have 5 fields field1...field5 in my formik form.I am using Yup for schema validation. Only one of field1, field2,field3 are mandatory at a given time. Field4 and Field5 have independent validations which do not have any dependency of other fields whatsoever. I have figured a way of writing</p>
  <pre><code>schema = Yup.object().shape({
    field1: Yup.string().when(['field2', 'field3'], {
       is: (field2, field3) =&gt; !field2 &amp;&amp; !field3,
       then: Yup.string().required()
  }),
    field2: Yup.string().when(['field1', 'field3'], {
       is: (field1, field3) =&gt; !field1 &amp;&amp; !field3,
       then: Yup.string().required()
  }),
    field3: Yup.string().when(['field1', 'field2'], {
       is: (field1, field2) =&gt; !field1 &amp;&amp; !field2,
       then: Yup.string().required()
  }),
     field4: Yup.string().max(30, &quot;Maximum 30 characters are allowed&quot;).required(&quot;This is a mandatory field&quot;),
     field5: Yup.string().max(30, &quot;Maximum 30 characters are allowed&quot;).required(&quot;This is a mandatory field&quot;)
  }
  ,[['field1', 'field2'], ['field1', 'field3'], ['field2','field3']]
  )
  </code></pre>
  <p>Please observe field4 and field5 are not mentioned in the second last line since they are not dependent on other fields. I mentioned field1,field2,field3 on the second last line since without it, the schema throws a cyclic dependency issue.</p>
  <p><strong>My Question is</strong>: Is the placement of field4 and field5 correct in the below schema.</p>