Defs & RulesLast updated on
Last updated on
Typed computed values and validation rules
Defs and Rules enable conditional behavior and validation in forms and bundles.
- Defs define typed computed values that can be referenced in field/annex conditions (
visible,required) - Rules define form-level validation constraints evaluated at fill time
DefsSection
A mapping of named typed expressions keyed by camelCase identifier.
Each entry specifies a type and value. For scalar types the value is a string expression; for composite types (money, address, etc.) the value is an object with component expressions, in the same shape as the matching field value. A bbox value has southWest and northEast corners, each with lat and lon expressions.
The keys fields and parties are reserved for the context roots, and item and parent for list row references. A def with one of these keys fails validation.
RulesSection
A mapping of form-level validation rules keyed by camelCase identifier. Rules are evaluated at fill time.
CondExpr
A conditional expression used in include, required, and visible fields.
type CondExpr = boolean | stringWhen a string is provided, it can reference:
- Named defs from the
defssection - Field values using
fields.<fieldName>(composite parts asfields.<fieldName>.<part>, e.g.fields.rent.amount) - Inside a list item, the current row as
itemand, in a nested list, the enclosing row asparent(e.g.item.kind == 'other') - Comparison operators (
==,!=,>,<,>=,<=) - Logical operators (
and,or,not) - Membership operators (
in,not in)
Validation rules (rules) may also reference field values unprefixed (e.g. creditScore). See Logic for the full expression language.
Examples
$schema: https://schema.paradoc.dev/2026-10-02.json
kind: form
name: loan-application
defs:
isEmployed:
type: boolean
value: "fields.employmentStatus == 'employed'"
needsCoSigner:
type: boolean
value: "fields.creditScore < 650"
showIncomeFields:
type: boolean
value: "isEmployed"
rules:
creditScoreRange:
expr: "creditScore >= 300 and creditScore <= 850"
message: "Credit score must be between 300 and 850"
incomeRequired:
expr: "not isEmployed or monthlyIncome.amount > 0"
message: "Monthly income is required for employed applicants"
severity: error
fields:
employmentStatus:
type: enum
label: Employment Status
enum: [{ value: "employed" }, { value: "self-employed" }, { value: "unemployed" }, { value: "retired" }]
creditScore:
type: number
label: Credit Score
min: 300
max: 850
employer:
type: text
label: Employer Name
visible: showIncomeFields
required: showIncomeFields
monthlyIncome:
type: money
label: Monthly Income
visible: showIncomeFields
required: showIncomeFields
coSignerName:
type: person
label: Co-Signer
visible: needsCoSigner
required: needsCoSigner