Skip to content

Tables

Tables can be validated for structure, headers, and cell content using matchers.

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 |

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

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

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 |

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:

  1. Match the literal “Header” row
  2. Match 1-3 repeating rows with the pattern
  3. 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)