formik icon indicating copy to clipboard operation
formik copied to clipboard

Add a delayed validateOnChange option

Open daviddonovski-allocate opened this issue 2 years ago • 0 comments

Feature request

I would like to see a validateOnChange pattern implemented that only performs validation AFTER the user stops typing in the field.

Current Behavior

The current validateOnChange option fires the validation after every single change in one of the fields. If server-side validation is used, it means a request would be sent with every letter typed.

Desired Behavior

This additional delayedValidateOnChange option would only perform validation a second or so after the user stops typing in the field. This would be extremely useful for cases where users have server-side validation implemented, so as not to send a million requests on every single letter typed. Validating on blur is only a stopgap measure here (since that way the form doesn't react immediately once the user fixes their field).

Suggested Solution

I presume this can be easily implemented by making a copy of the validateOnChange code, but only firing the validation call if a second has passed since the user last typed in the field.

Who does this impact? Who is this for?

Users who use server-side validation but still want the form to update the validation messages when a field is changed (but not send an unnecessary amount of requests).

daviddonovski-allocate avatar Aug 23 '22 13:08 daviddonovski-allocate