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:

OperatorMeaningExample
eqEqual to"value": "closed"
neqNot equal to"value": "active"
gtGreater than"value": 100
gteGreater than or equal"value": 4
ltLess than"value": 0
lteLess than or equal"value": -0.05
inValue is in array"value": ["US", "CA"]
not_inValue is not in array"value": ["EU", "UK"]
containsString contains substring"value": "warning"
existsField is present and non-null"value": true
not_existsField 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 set
  • suppress_field — Hides a specific field from presentation
  • override_display_rule — Modifies how a field is formatted