Conditionals
All conditional builders return a JSONSchema object. Combine them with and, or, and not. Use them in field or action conditionals arrays.
field (conditionals)
field (conditionals)Entry point for building conditions on a form field's value.
Signature
function field(fieldId: string): FieldConditionalBuilderThe returned builder exposes these methods:
.isEqualTo(value)
Field equals a literal value or another field reference.
.isFalsy()
Field is undefined, false, null, or ''.
.isUndefined()
Field has never been set.
.inArray(values)
Field value is one of the given strings.
.matches(pattern)
Field value matches a regex pattern string.
.isBetween(min, max)
Numeric field falls within an inclusive range.
.isGreaterThan(value)
Numeric field is strictly greater than a number or another field.
.isLessThan(value)
Numeric field is strictly less than a number or another field.
.isValidEnglishName()
Value contains only Latin letters, digits, hyphens, apostrophes, and dots.
.isValidAdministrativeLeafLevel()
Address field points to the lowest administrative level.
.get(path)
Navigate into a nested property before applying a check (e.g. .get('dob')).
.getByPath(parts)
Same as .get but accepts a string array.
.asDob()
Shorthand for .get('dob').
.asAge()
Shorthand for .get('age').
.isAfter().days(n).inPast()
Date is more than n days ago.
.isAfter().days(n).inFuture()
Date is more than n days in the future.
.isAfter().days(n).fromDate(date)
Date is at least n days after a fixed date or field reference.
.isAfter().date(date)
Date is after a fixed ISO date or another field reference (no day tolerance).
.isAfter().now()
Date is in the future.
.isBefore().days(n).inPast()
Date is fewer than n days ago.
.isBefore().days(n).fromDate(date)
Date is fewer than n days before a fixed date or field reference.
.isBefore().now()
Date is in the past.
Example 1 — show a field only when another field has a specific value
Example 2 — hide a field when it has no value
field.get — nested field access
field.get — nested field accessNavigates into an object-typed field before applying a check.
Signature
Parameters
fieldId
string
Top-level field ID.
path
string
Dot-separated path to a nested property.
Example 1 — validate each part of a name field
Example 2 — check the address type
and
andAll supplied conditions must be true.
Signature
Parameters
...conditions
JSONSchema[]
Two or more conditional schemas to combine.
Example 1 — require both a valid name and a valid date
Example 2 — name validator used in a field's validations array
or
orAt least one of the supplied conditions must be true.
Signature
Parameters
...conditions
JSONSchema[]
Two or more conditional schemas to combine.
Example 1 — accept multiple place-of-birth values
Example 2 — show address block when country is unset or local
not
notInverts a condition.
Signature
Parameters
condition
JSONSchema
The condition to negate.
Example 1 — show a field when it has a value
Example 2 — display international address fields
alwaysTrue
alwaysTrueReturns a condition that is always satisfied. Useful as a no-op placeholder.
Signature
Example 1 — unconditionally show a field
Example 2 — use as a default branch in a conditional expression
never
neverReturns a condition that is never satisfied. Use it to hide a field or action completely.
Signature
Example 1 — hide a field from end users entirely
Example 2 — disable an action for all users
flag
flagChecks whether a named flag is currently set on the event.
Signature
Parameters
flagValue
string
The flag ID to check for. Must match an entry in EventConfig.flags.
Example 1 — show an action only when a flag is set
Example 2 — require approval step for late registrations
status
statusChecks the current registration status of an event.
Signature
Parameters
statusValue
EventStatus
One of 'CREATED', 'NOTIFIED', 'DECLARED', 'VALIDATED', 'REGISTERED', 'REJECTED', 'ARCHIVED', 'CORRECTION_REQUESTED'.
Example 1 — show register action only after declaration
Example 2 — enable correction only after registration
user.hasScope
user.hasScopeChecks whether the current user has a particular scope string in their token.
Signature
Parameters
scope
string
A scope string such as 'record.register' or 'record.declare'.
Example 1 — show register action only for registrars
Example 2 — allow printing only for users with the print scope
user.hasRole
user.hasRoleChecks whether the current user has a specific role.
Signature
Parameters
role
string
Role identifier as defined in the country configuration (e.g. 'REGISTRAR').
Example 1 — show a review action only for local registrars
Example 2 — disable national-level actions for field agents
user.isOnline
user.isOnlineReturns true when the user has an active internet connection.
Signature
Example 1 — require online for biometric verification
Example 2 — show an offline banner field when disconnected
event.hasAction
event.hasActionChecks whether the event's action history contains a specific action type.
Signature
Parameters
action
ActionType
The action type to look for in the event's action list.
.minCount(n)
—
Require at least n occurrences of the action.
.maxCount(n)
—
Require at most n occurrences.
.withTemplate(id)
—
Further filter by certificate template ID.
.withFields(fields)
—
Further filter by arbitrary action fields.
Example 1 — show issue-certified-copy only after first certificate was printed
Example 2 — limit re-printing to at most one time
defineFormConditional
defineFormConditionalLow-level escape hatch for writing a raw JSON Schema conditional against form data. The schema is automatically wrapped so it validates against $form.
Signature
Parameters
schema
Record<string, unknown>
A JSON Schema object that will be evaluated against the form state.
Example 1 — validate a national ID with a regex
Example 2 — require a field to be a positive integer
Last updated