Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use low priority validation for FieldArray #2707

Closed
2 changes: 1 addition & 1 deletion packages/formik/src/FieldArray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class FieldArrayInner<Values = {}> extends React.Component<
getIn(this.props.formik.values, this.props.name)
)
) {
this.props.formik.validateForm(this.props.formik.values);
this.props.formik.validateFormWithLowPriority(this.props.formik.values);
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/formik/src/Formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
resetForm,

validateForm: validateFormWithHighPriority,
validateFormWithLowPriority,
validateField,
setErrors,
setFieldError,
Expand Down Expand Up @@ -1031,6 +1032,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
setValues,
submitForm,
validateForm: validateFormWithHighPriority,
validateFormWithLowPriority,
validateField,
isValid,
dirty,
Expand Down
2 changes: 2 additions & 0 deletions packages/formik/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export interface FormikHelpers<Values> {
) => void;
/** Validate form values */
validateForm: (values?: any) => Promise<FormikErrors<Values>>;
/** Validate form values w/o blocking UI */
validateFormWithLowPriority: (values?: any) => void;
/** Validate field value */
validateField: (field: string) => void;
/** Reset form */
Expand Down
2 changes: 2 additions & 0 deletions packages/formik/test/withFormik.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('withFormik()', () => {
unregisterField: expect.any(Function),
validateField: expect.any(Function),
validateForm: expect.any(Function),
validateFormWithLowPriority: expect.any(Function),
validateOnBlur: true,
validateOnMount: false,
validateOnChange: true,
Expand Down Expand Up @@ -192,6 +193,7 @@ describe('withFormik()', () => {
setValues: expect.any(Function),
validateField: expect.any(Function),
validateForm: expect.any(Function),
validateFormWithLowPriority: expect.any(Function),
submitForm: expect.any(Function),
}
)
Expand Down