Tables
Tables can be validated for structure, headers, and cell content using matchers.
Basic Table Matching
Section titled “Basic Table Matching”Tables match literally by default - headers and all rows must match exactly:
schema.mds
| Name | Age || :--- | :-- || Alice | 25 || Bob | 30 |input.md
| Name | Age || :--- | :-- || Alice | 25 || Bob | 30 |schema.mds
| Name | Age || :--- | :-- || Alice | 25 |input.md
| Name | Age || :--- | :-- || Bob | 30 |Table Headers
Section titled “Table Headers”Headers can use matchers to validate column names:
schema.mds
| buzz `col:/\w+/` bar | `col:/\w+/` || :--- | :-- || data | more |input.md
| buzz Name bar | Age || :--- | :-- || data | more |Output:
{"col":["Name","Age"]}Cell Content Validation
Section titled “Cell Content Validation”Individual cells can contain matchers:
schema.mds
| Name | Phone || :--- | :---- || `name:/\w+/` | `phone:/\d{3}-\d{4}/` |input.md
| Name | Phone || :--- | :---- || Alice | 555-1234 |Output:
{"name":"Alice","phone":"555-1234"}Repeated Rows
Section titled “Repeated Rows”Use {min,max} syntax on row patterns to match multiple rows:
schema.mds
| Item | Price || :--- | :---- || `item:/\w+/` | `price:/\d+/` |{1,3}input.md
| Item | Price || :--- | :---- || Apple | 2 || Banana | 3 |Output:
{"item":["Apple","Banana"],"price":["2","3"]}schema.mds
| Type | Number || :--- | :----- || `type:/\w+/` | `number:/\d+/` |{2,}input.md
| Type | Number || :--- | :----- || Backup | 212 || Misc | 123 |Output:
{"type":["Backup","Misc"],"number":["212","123"]}schema.mds
| Item | Price || :--- | :---- || `item:/\w+/` | `price:/\d+/` |{1,3}input.md
| Item | Price || :--- | :---- || Apple | 2 || Banana | 3 || Cherry | 4 || Date | 5 |Mixing Literal and Repeated Rows
Section titled “Mixing Literal and Repeated Rows”You can combine literal rows with repeated rows in the same table:
schema.mds
| Item | Price || :--- | :---- || Header | 10 || `item:/\w+/` | `price:/\d+/` |{1,3}| Footer | 99 |input.md
| Item | Price || :--- | :---- || Header | 10 || Apple | 5 || Banana | 3 || Footer | 99 |Output:
{"item":["Apple","Banana"],"price":["5","3"]}The validator will:
- Match the literal “Header” row
- Match 1-3 repeating rows with the pattern
- Match the literal “Footer” row
- Repeated rows return arrays for matched values
- Headers and separator rows are required in both schema and input
- Column count must match between schema and input
- Repeated row patterns must appear at the end of a row (after all cells)