Overview
Async validators are supported only on the plain-object track: schema and validateObject. Signature: async (value, signal?) => string | null.
Pass signal to fetch (or other cancellable I/O). When a newer run starts, Mates aborts the prior AbortSignal so stale responses do not win.
formAtom / useForm are intentionally sync — a Promise result throws. Bind inputs with FormAtoms, then run schema (with async rules) on submit or the server.
Sync vs async
|
API
|
Async validators
|
Signal
|
|---|---|---|
formAtom / useForm
| Throws | N/A |
schema / validateObject
| Awaited | options.signal or internal |
Async rule on schema
Simulated uniqueness — replace setTimeout with fetch(..., { signal }).
AbortSignal — cancel prior run
Pass { signal } to validateObject. Rapid restarts abort the previous validator.
formAtom rejects async validators
validate() / set() throw with a clear message.