Open mschipperheyn opened 5 years ago
What if you throw undefined?
imho indicating (async) validation errors with throwing something is "wrong". The sync and async validation should be consistent: async validation should just return/resolve an object (an empty object would indicate no validation errors in both cases) see also https://github.com/jaredpalmer/formik/issues/966
🐛 Bug report
Current Behavior
If you throw an empty errors object, validation passes validation successfully
Expected behavior
While in sync mode returning an empty errors object is supposed to pass validation, in async mode, the fact that the Promise throws is already an indication that an error occurred, otherwise it would simply return the empty object instead of throwing it.
This can lead to subtle errors if server side validation messages are processed and an error gets thrown during this process.
Reproducible example
Suggested solution(s)
Any scenario where async validation throws, should lead to a failed validation.
Your environment