title: How to call a method on form submission if there is a validation error using Formik + Yup?
body: <p>I am working on react native application where using Formik and Yup for forms. I want to update one state value depending on the form's value while submitting a form.</p>
  
  <p><strong>Issue Description::</strong></p>
  
  <p>It works fine if there is no validation error, but there is one address field and depending on that field I have added a hidden field "zipcode". I want to show zipcode input text field if my address is empty.</p>
  
  <p><strong>Code::</strong></p>
  
  <pre><code>const validationSchema = Yup.object().shape({
      address: Yup.string()
          .required('Address should not be empty'),
      zipcode: Yup.string()
          .required(errMgs.emptyText)
          .matches(regExp, errMgs.specialCharNotAllowed),
      apt: Yup.string()
          .matches(regExp, errMgs.specialCharNotAllowed)
  });
  </code></pre>
  
  <p>Inside render function::</p>
  
  <pre><code>&lt;Formik
      initialValues={this.initialValues}
      onSubmit={(data) =&gt; this.onSubmitForm(data)}
      ref={el =&gt; (this.form = el)}
      validationSchema={validationSchema}
      render={({ handleSubmit, values, setValues, setFieldValue, errors, touched, ...props }) =&gt; {
          return (
              &lt;Form&gt;
                  &lt;GooglePlacesInput
                      onPress={(data, detail) =&gt; this.onPressOfAddress(data, detail)}
                      address={values.address}
                      name="address"
                      onChangeText={(value) =&gt; setFieldValue('address', value)}
                  /&gt;
                  {errors.address &amp;&amp; touched.address &amp;&amp; &lt;ErrorText message={errors.address} /&gt;}
                  {isZipCode &amp;&amp;
                      &lt;&gt;
                          &lt;TextInput placeholder="Zipcode" textContentType="postalCode" name="zipcode" type="text" onValueChange={(value) =&gt; this.onChangeZipcode(value)} /&gt;
                          {errors.zipcode &amp;&amp; touched.zipcode &amp;&amp; &lt;ErrorText message={errors.address} /&gt;}
                      &lt;/&gt;
                  }
                  &lt;TextInput placeholder="apt" textContentType="streetAddressLine1" name="apt" type="text" onValueChange={(value) =&gt; setFieldValue('apt', value)} /&gt;
                  &lt;Button onPress={handleSubmit} block large variant="success"&gt;SAVE&lt;/Button&gt;
                  &lt;Button onPress={() =&gt; popScreen(this.props.componentId)} block large variant="danger"&gt;CANCEL&lt;/Button&gt;
              &lt;/Form&gt;
          );
      }}
  /&gt;
  </code></pre>
  
  <p>I want to show zip code input with error when my address is empty on submission, means when there is a validation error in the form. How can I do this?</p>