Overview
Mates forms split into two tracks. formAtom / useForm are sync reactive fields for the UI (.errors, .isValid, .dirty). schema / validateObject validate plain snapshots and support async validators — use them on submit and on the server.
Do not mix a FormAtom into a schema definition. Prefer await checkValidation(body, schema) from mates-fullstack in handlers. Templates should read isValid() / field.isValid, not call validateObject during render.
Deep pages: formAtom, useForm, validators, schema & combinators, async validation.
Which track
|
Piece
|
Input
|
Notes
|
|---|---|---|
formAtom
| One field (sync) | UI binding; validates on set once dirty |
useForm
| Tree of FormAtoms (sync) | { form, updateForm, isValid, validate } |
schema
| Plain object (async OK) | Shared client/server; nestable |
validateObject
| Snapshot + schema node | What schema() calls under the hood |
Track 1 — formAtom + validateAll
One formAtom per field. validateAll walks the object, calls validate(), and returns isValid.
Track 2 — schema() on a plain snapshot
atom holds the snapshot. userSchema(data()) on the client is the same function as userSchema(body) on the server.