Conditional fields
A field appears only when a condition holds, live as the person types, and a hidden required field is skipped by validation on both sides.
The situation
A rejection needs a reason; an approval does not. One form should ask for the reason only when the reviewer rejects, and the reason should be required exactly when it shows.
The recipe
{ "title": "Quality review", "x-lt-order": ["approved", "rejection_reason", "notes"], "required": ["rejection_reason"], "properties": { "approved": { "type": "boolean", "description": "Approve this submission" }, "rejection_reason": { "type": "string", "format": "textarea", "x-lt-showIf": "!resolver.approved" }, "notes": { "type": "string", "format": "textarea" } }}The value at the path is tested for truthiness; ! inverts. Equality forms compare a string: resolver.station=DRAFT, metadata.count!=3. An array requires every condition.
| Domain | Reads |
|---|---|
resolver, input |
The live form values, reacting as the person edits |
metadata, payload, envelope, escalation |
The stored row |
roster |
A roster field’s counts, such as roster.orders.outstanding=0 |
The guarantee
Required validation is skipped for fields hidden at submission time. For roles with enforce_schema, the server evaluates the same conditions with the same shared pass, so a hidden field is optional and a shown required field is enforced through every surface, with the canonical 422 on a miss. In the workflow, treat the conditional fields as optional. See Forms.
Related patterns
Forms and configuration
The form is data
A role's form is a versioned JSON Schema; each row pins the edition it renders, so editing the form never breaks work in flight.
Forms and configuration
Roster: check off who arrived
A roster lists every member a container expects, marks each waiting, in or flagged, and holds the rest of the form until all are accounted for.
Resolving from anywhere
One contract, one 422
Every resolve surface rejects a bad payload with the same 422 body naming each field, so every client handles validation one way.
