TBL-004 Cell pattern
Overview
Section titled “Overview”Validates that the cell values in a specific column match the regular expression given by pattern. Non-matching values trigger an error.
Why it matters
Section titled “Why it matters”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.
Options
Section titled “Options”| Field | Type | Required | Description |
|---|---|---|---|
column | string | Yes | Column name to validate |
pattern | string | Yes | Regular expression (JavaScript RegExp syntax; validated at config load time) |
files | string | — | Glob of files this rule applies to |
Bad example
Section titled “Bad example”| 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-004After fix
Section titled “After fix”| ID | Description || ---------- | ----------------- || REQ-001 | User registration || REQ-002 | Password reset |Configuration example
Section titled “Configuration example”{ "rule": "tbl004", "options": { "column": "ID", "pattern": "^REQ-\\d{3}$" }}In JSON, backslashes must be escaped, so \d is written as \\d.
Related rules
Section titled “Related rules”- TBL-003 Allowed values — Constrain values by list (simpler than a pattern)
- TBL-005 Cross-column constraints — Constrain relationships between columns