The validation handler function is not called with formikBag
Call validation function handler with formikBag
validate(values, formikBag)
This helps to allow passing results from the validation function back into the form i.e. through setStatus
This would encourage side effects in validation within Formik which is a bad practice. I鈥檓 not sure why you want to pass back results into the form as they are already available everywhere thru errors.
One reason could be to set a loading indicator via setStatus.
I would like to run certain rules (sync) on onChange, and other rules (sync+async) onBlur (and set a loading indicator while the async rules are loading).
With access to FormikBag or parts of the FormikBag, this would be possible and very simple to do - without causing to much side effects.
Yea, in my validator, I perform a complex calculation from inputs as part of the form validation process. I understand that it would cause side effects, but it would be nice to have a way to pass the results of calculations since the operation is expensive and I do not want to repeat the operation outside of formik.
I too would like to setStatus in the validate function!!! you can eventually just do it in submit handler, or if you really want to on a custom onChange/onBlur for a field where it has access.
Most helpful comment
Yea, in my validator, I perform a complex calculation from inputs as part of the form validation process. I understand that it would cause side effects, but it would be nice to have a way to pass the results of calculations since the operation is expensive and I do not want to repeat the operation outside of formik.