> ## Documentation Index
> Fetch the complete documentation index at: https://docs.frayme.io/llms.txt
> Use this file to discover all available pages before exploring further.

# rule

> First-match conditions producing named output fields. The smallest, most common decision node.

A `rule` node evaluates a list of `conditions` in order, the first match wins. Each condition has one or more `clauses` joined by an `AND` or `OR` `logicOperator`. The matching condition's `outputValues` are written to the top-level run context. If nothing matches, `elseValues` is written.

## Configuration

```jsonc theme={null}
{
  "id": "rl-region",
  "type": "rule",
  "data": {
    "label": "Region Two-Layer Check",
    "outputFields": ["region_check", "region_reason"],
    "description": "...",
    "conditions": [
      {
        "id": "cond-allow",
        "logicOperator": "AND",
        "clauses": [
          {
            "variable": "input.declared_country",
            "operator": "in",
            "value": "BR,US,GB,DE,FR,...",
          },
          {
            "variable": "input.declared_country",
            "operator": "not_in",
            "value": "IR,KP,SY,...",
          },
        ],
        "outputValues": {
          "region_check": "pass",
          "region_reason": "On commercial allowlist and not on prohibitions list",
        },
      },
      {
        "id": "cond-fatf",
        "logicOperator": "OR",
        "clauses": [
          {
            "variable": "input.declared_country",
            "operator": "in",
            "value": "TR,VN,PH,NG,KH",
          },
        ],
        "outputValues": {
          "region_check": "manual_review",
          "region_reason": "FATF grey list — handle via compliance review",
        },
      },
    ],
    "elseValues": {
      "region_check": "reject",
      "region_reason": "Country not supported or prohibited by policy",
    },
  },
}
```

## Operators

| Operator                 | Use                                         |
| ------------------------ | ------------------------------------------- |
| `==`, `!=`               | Equality.                                   |
| `>`, `>=`, `<`, `<=`     | Numeric comparison.                         |
| `in`, `not_in`           | Membership in a comma-separated value list. |
| `matches`, `not_matches` | Regex.                                      |
| `exists`, `not_exists`   | Presence check (no value needed).           |

## Output fields

`outputFields` is the list of variable names the rule writes. Every condition (and the `elseValues`) must produce values for **every** declared field — engine refuses partial outputs.

## Composing with downstream nodes

The rule's outputs are top-level on the context, so downstream nodes reference them without a parent path:

```text theme={null}
{{region_check}}          // not {{rl-region.region_check}}
{{rewrite_valid}}
{{counterpart_edd_required}}
```

This is intentional — rules are the lightest-weight gates and shouldn't require a knowing parent.

## Rule vs decisionTable

|                | rule                                                 | decisionTable                                            |
| -------------- | ---------------------------------------------------- | -------------------------------------------------------- |
| **Evaluation** | First-match conditions, each with arbitrary clauses. | First-match rows on a fixed column set.                  |
| **Best for**   | Boolean gates with 2–5 outcomes.                     | Multi-input lookups (`band × recommendation → outcome`). |
| **Used by**    | Region gates, address length, AML decision.          | KYC outcome routers, auto-resolve routers.               |
