Async Validation and formatResult
We learned earlier that
formatResultcan be used to wrap a validator and augment or transform its validation result. This is true for async validation results as well--
formatResulthandles both synchronous and asynchronous results.
By simply wrapping a validator with
formatResult, the result formatter function will be called for both the synchronous and the asynchronous results. The two-stage sync/async validation results can be differentiated from one another if needed. If the result contains a
validateAsyncresult prop (that is a function), then the result represents the first stage, synchronous validation result. If the result does not contain a
validateAsyncresult prop, then all asynchronous validation has been completed.