title: Confirm Password with Formik
body: <p>I'm trying to use formik's field validation to confirm password authentication. But i was having trouble trying to compare the password and confirm password</p>
  
  <p>So far I have 
  register.js</p>
  
  <pre><code>&lt;Formik
          initialValues={{
          password: "",
          confirmPassword: "",
          }}
          onSubmit={(values, actions, { validate }) =&gt; {
                      validate(values);
                      register(values);
                      actions.resetForm();
                  }}
         &gt;
                  {({ errors, touched, validateForm }) =&gt; (
                      &lt;Form className={styles.form}&gt;
  
          &lt;Field
                type="password"
                name="password"
                validate={validatePassword}
                /&gt;            
          &lt;Field
                type="password"
                name="confirmPassword"
                validatePassword={confirmPassword}
                /&gt;                        
            &lt;button type="submit" onClick={() =&gt; validateForm()}&gt;
                              {!isLoading ? "Register" : &lt;Loader /&gt;}
                          &lt;/button&gt;
                      &lt;/Form&gt;
                  )}
              &lt;/Formik&gt;
  </code></pre>
  
  <p>with validation looking like this. </p>
  
  <pre><code>function validatePassword(values) {
      let error = {};
      const passwordRegex = /(?=.*[0-9])/;
      if (!values) {
          error = "*Required";
      } else if (values.length &lt; 8) {
          error = "*Password must be 8 characters long.";
      } else if (!passwordRegex.test(values)) {
          error = "*Invalid password. Must contain one number.";
      }
      return error;
  }
  </code></pre>