Skip to content

Field Validation validates all fields? #2630

Answered by maddhruv
RoosterH asked this question in General
Discussion options

You must be logged in to vote

When you have individual validators for the field, Formik validates individual files (onChange or onBlur depending upon the config). If you want to run validation on all the fields, there is a method returned by formik called validateForm, which you can easily call and validate the whole form. You can find more reference here -

Example code you can refer

<Formik
      initialValues={{
        username: '',
        email: '',
      }}
      onSubmit={values => {
        // same shape as initial values
        console.log(values);
      }}
>
      {({ errors, to…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by maddhruv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants