콘텐츠로 이동

TBL-005 컬럼 간 제약

한 컬럼이 when의 조건을 만족할 때, 다른 컬럼이 then의 제약을 만족하는지를 검증합니다. 조건부 규칙으로, 행마다 평가됩니다. 위반은 error 로 보고됩니다.

Statusstable일 때는 Approver 컬럼이 비어 있지 않을 것」「Typeexternal일 때는 URL 컬럼이 https://로 시작할 것」 같은 행 내의 조건부 정합성 은 허용 값이나 정규표현식만으로는 표현할 수 없습니다. 이 규칙은 그러한 컬럼 간의 관계를 표현합니다.

필드타입필수설명
whenobject조건(아래 참조)
thenobject제약(아래 참조)
sectionstring검증 대상을 특정 섹션 하위의 테이블로 한정
filesstring이 규칙을 적용할 파일의 glob
필드타입설명
columnstring조건을 판정할 컬럼
equalsstring값이 이 문자열과 일치할 때
oneOfstring[]값이 이 배열의 어느 하나에 포함될 때
matchesstring값이 정규표현식과 일치할 때

equals / oneOf / matches는 그 중 하나만 지정합니다.

필드타입설명
columnstring제약을 가할 컬럼
notEmptyboolean값이 비어 있지 않을 것
equalsstring값이 일치할 것
oneOfstring[]값이 포함될 것
matchesstring값이 일치할 것

notEmpty / equals / oneOf / matches는 그 중 하나만.

| ID | Status | Approver |
| ------ | ------ | -------- |
| REQ-01 | stable | alice |
| REQ-02 | stable | |

when: { column: "Status", equals: "stable" }, then: { column: "Approver", notEmpty: true }를 설정한 경우, stable인데 Approver가 빈 행이 위반이 됩니다.

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