TBL-005 Cross-column constraints
Overview
Section titled “Overview”Validates that when one column satisfies the when condition, another column satisfies the then constraint. The rule is conditional and is evaluated row by row. Violations are reported as error.
Why it matters
Section titled “Why it matters”Constraints like “when Status is stable, the Approver column must not be empty” or “when Type is external, the URL column must start with https://” express intra-row conditional consistency that allowed values or regex patterns cannot capture on their own. This rule expresses such relationships between columns.
Options
Section titled “Options”| Field | Type | Required | Description |
|---|---|---|---|
when | object | Yes | Condition (see below) |
then | object | Yes | Constraint (see below) |
section | string | — | Restrict validation to tables under a specific section |
files | string | — | Glob of files this rule applies to |
when (condition)
Section titled “when (condition)”| Field | Type | Description |
|---|---|---|
column | string | Column the condition is evaluated on |
equals | string | Triggers when the value equals this string |
oneOf | string[] | Triggers when the value is in this array |
matches | string | Triggers when the value matches this regex |
Specify exactly one of equals / oneOf / matches.
then (constraint)
Section titled “then (constraint)”| Field | Type | Description |
|---|---|---|
column | string | Column the constraint is applied to |
notEmpty | boolean | Value must not be empty |
equals | string | Value must equal this string |
oneOf | string[] | Value must be in this array |
matches | string | Value must match this regex |
Specify exactly one of notEmpty / equals / oneOf / matches.
Bad example
Section titled “Bad example”| ID | Status | Approver || ------ | ------ | -------- || REQ-01 | stable | alice || REQ-02 | stable | |With when: { column: "Status", equals: "stable" } and then: { column: "Approver", notEmpty: true }, the row whose Status is stable but whose Approver is empty triggers a violation.
docs/requirements.md line 4 error Row where Status="stable": column "Approver" must not be empty TBL-005After fix
Section titled “After fix”| ID | Status | Approver || ------ | ------ | -------- || REQ-01 | stable | alice || REQ-02 | stable | bob |Configuration example
Section titled “Configuration example”{ "rule": "tbl005", "options": { "when": { "column": "Status", "equals": "stable" }, "then": { "column": "Approver", "notEmpty": true } }}Related rules
Section titled “Related rules”- TBL-003 Allowed values — Single-column value constraints
- TBL-004 Cell pattern — Single-column pattern constraints