Skip to content

TBL-005 Cross-column constraints

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.

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.

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
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.

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.

| 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-005
| ID | Status | Approver |
| ------ | ------ | -------- |
| REQ-01 | stable | alice |
| REQ-02 | stable | bob |
{
"rule": "tbl005",
"options": {
"when": { "column": "Status", "equals": "stable" },
"then": { "column": "Approver", "notEmpty": true }
}
}