Conditionals
Conditional rules let contracts adapt their requirements based on the data values or user context. Rules that activate only when they are relevant.
Why conditionals?
A fixed set of disclosures works for simple cases, but real-world data is nuanced. A fund with a risk rating of 2 needs different disclosures than one rated 5. A drug interaction warning only applies when specific medications are combined. Conditionals make contracts context-aware.
Structure
Each conditional rule has three parts: an id, a condition, and a then action:
{
"id": "high-risk-warning",
"condition": {
"field": "payload.fund_info.risk_rating",
"operator": "gte",
"value": 4
},
"then": {
"add_disclosure": {
"id": "high-risk-disc",
"text": "This fund has above-average risk. You could lose a significant portion of your investment.",
"verbatim": true,
"scope": ["fund_info.risk_rating"],
"placement": "adjacent",
"priority": "required"
}
}
}
Field conditions
Field conditions evaluate values from the payload. The field path uses dot notation:
"condition": {
"field": "payload.price.change_pct",
"operator": "lt",
"value": -0.1
}
This triggers when the price change is less than -10%.
Context conditions
Context conditions evaluate values from the user's context (e.g., jurisdiction, account type, risk tolerance). The runtime receives user context at initialization:
"condition": {
"context": "user.jurisdiction",
"operator": "eq",
"value": "EU"
}
This triggers jurisdiction-specific disclosures automatically.
Operators
All available operators for conditions:
| Operator | Meaning | Example |
|---|---|---|
eq | Equal to | "value": "closed" |
neq | Not equal to | "value": "active" |
gt | Greater than | "value": 100 |
gte | Greater than or equal | "value": 4 |
lt | Less than | "value": 0 |
lte | Less than or equal | "value": -0.05 |
in | Value is in array | "value": ["US", "CA"] |
not_in | Value is not in array | "value": ["EU", "UK"] |
contains | String contains substring | "value": "warning" |
exists | Field is present and non-null | "value": true |
not_exists | Field is absent or null | "value": true |
Then actions
When a condition is met, the then block can perform one of three actions:
add_disclosure— Adds a new disclosure to the active setsuppress_field— Hides a specific field from presentationoverride_display_rule— Modifies how a field is formatted