react-final-form icon indicating copy to clipboard operation
react-final-form copied to clipboard

Revalidate without submit

Open gabrielgrs opened this issue 4 years ago • 2 comments

Good afternoon guys, how are you?

I have a scenario where I need to revalidate some fields, but I don't want to change the meta.touched to true.

Is there any way to trigger the validation of all fields in a practical way?

Thanks!

gabrielgrs avatar Apr 29 '21 19:04 gabrielgrs

I also needed to trigger validation and found out, that there is not such public API. Luckily, there is a workaround. The (somewhat less known) Mutator API runs validation practically with everything (see the source code for mutators, where it calls runValidate with undefined which runs validate on all registered fields).

I link CodeSandbox with an example of such mutator in this comment.

czabaj avatar May 10 '21 08:05 czabaj

HI, @czabaj problem is your example is only one field it works fine when you add multiple fields then if (meta.active) return undefined; meta. active always false then very keypress it will call async servcie

deathcave avatar Aug 24 '24 17:08 deathcave