Overview
schema((obj) => definition) builds a reusable async validator for plain objects. Always await. The factory receives the current object so fields can close over siblings (isEqualTo(() => obj.password)).
validateObject(data, node) is the engine — schema() calls it. Nest schemas as fields, or use combinators: optional, validateOnlyIf, validateEach, validateTuple.
validateAll is the FormAtom walker (sync) — different track. Do not pass FormAtoms into a schema.
Helpers
|
API
|
Input
|
Async?
|
|---|---|---|
schema / validateObject
| Plain snapshot | Yes — always await |
validateAll
| FormAtom tree | Sync only |
validateCustom
| Imperative errors bag | Sync or async cb |
schema() — shared client / server
atom holds the snapshot. Same function on the server with body.
Nested schemas — validateEach + optional
Pass a schema as a field. validateEach applies it to every array item.
Conditional — validateOnlyIf
predicate receives { value, parent, root, path }. Maiden name required only when gender is female.
validateCustom + validateTuple
Ad-hoc cross-field errors; positional schemas for fixed-length arrays.