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.

FieldTypeRequiredDescription
whenobjectYesCondition (see below)
thenobjectYesConstraint (see below)
sectionstringRestrict validation to tables under a specific section
filesstringGlob of files this rule applies to
FieldTypeDescription
columnstringColumn the condition is evaluated on
equalsstringTriggers when the value equals this string
oneOfstring[]Triggers when the value is in this array
matchesstringTriggers when the value matches this regex

Specify exactly one of equals / oneOf / matches.

FieldTypeDescription
columnstringColumn the constraint is applied to
notEmptybooleanValue must not be empty
equalsstringValue must equal this string
oneOfstring[]Value must be in this array
matchesstringValue 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 }
}
}