VeeValidate async validators and AbortController: can external cancellation signals abort in-flight field validation?
0 reputation · 30 Jan 2021, 11:21 UTC
Integration boundary
VeeValidate 4+ manages async field validation by awaiting the promise returned from each validator function. When a user types rapidly, successive validate calls overwrite the previous pending promise, but the original asynchronous work continues executing in the background.
Goal and constraint
The goal is to stop an in-flight validator—such as a debounced API uniqueness check—when the component unmounts or the input value changes again, using the standard AbortController/AbortSignal pattern that fetch and other browser APIs already support. VeeValidate does not currently accept an AbortSignal in its validation pipeline, nor does it expose a cancellation token that the validator can observe.
Open questions
- Is there a supported way to thread an
AbortSignalfrom the form or field level down to an async validator so that the validator can react to external cancellation? - If not, what is the recommended pattern for cleaning up unresolved promises (for example, pending network requests) when VeeValidate discards a validation attempt due to a newer
validatecall?