Worked rule examples
Example 1 — age from a date of birth
A programme intake form asks for a date of birth and needs an age in whole years, displayed back to the respondent but never hand-typed by them — the two must never disagree.
Example 2 — a follow-up that is only sometimes required
The same intake form collects household size. Above six people, the programme's rules require a second form of identification for the extra household members — but asking every applicant for it, most of whom have small households, would be pure friction.
Example 3 — rejecting a contradiction across two fields
A monitoring visit form records a visit's start and end time. Neither field alone can be wrong, but the combination can be — an end time before the start time is a data-entry slip that should never reach the database.
Starting templates
Every rule above is common enough that you rarely need to build it node by node. The rule editor offers these as ready-made starting points — like picking a form letter instead of writing one from a blank page — so the common shapes are one click rather than four nested pickers. Each produces a tree that compiles as-is; you then swap a field or a constant to match your form.
| Template | Kind | What it builds |
|---|---|---|
| Age from date of birth | Calculate | yearsBetween(date_field, today()). Swap the date field to match your question. |
| Add two answers together | Calculate | Adds two numeric questions. Replace the second operand with another field or a constant. |
| Show when an answer matches | Show | Reveals a question when another has a specific value. Fill in the target value. |
| Show once something is answered | Show | Reveals a follow-up the moment an earlier question is filled in. |
| Require a follow-up | Require | Makes a question mandatory once another has any answer. |
| Reject a value outside a range | Validate | not(between(field, 0, 100)) — blocks submission when a number falls outside the allowed band. |