Skip to content

TBL-004 Cell pattern

Validates that the cell values in a specific column match the regular expression given by pattern. Non-matching values trigger an error.

When an ID column follows a fixed format like REQ-001, enforcing the format with pattern prevents notation drift (req001, REQ_001, #REQ-001, etc.). This is the right tool when expressing the format itself as a regex scales better than enumerating allowed values.

FieldTypeRequiredDescription
columnstringYesColumn name to validate
patternstringYesRegular expression (JavaScript RegExp syntax; validated at config load time)
filesstringGlob of files this rule applies to
| ID | Description |
| ---------- | ----------------- |
| REQ-001 | User registration |
| req-002 | Password reset |

With column: "ID", pattern: "^REQ-\\d{3}$", the lowercase req-002 triggers a violation.

docs/requirements.md
line 4 error Value "req-002" in column "ID" does not match pattern "^REQ-\d{3}$" TBL-004
| ID | Description |
| ---------- | ----------------- |
| REQ-001 | User registration |
| REQ-002 | Password reset |
{
"rule": "tbl004",
"options": {
"column": "ID",
"pattern": "^REQ-\\d{3}$"
}
}

In JSON, backslashes must be escaped, so \d is written as \\d.