Skip to content

VALIDATION-PLANES-12: Typed table columns with a per-row constraint

table({columns, cells, minRows}) types each named column with Zod and flags a bad cell at that row’s source line.

Builds on: VALIDATION-PLANES-07: Require a block kind: a table

A TypeScript program against the library API; inline comments show the resulting values and behavior.

const c = contract({ body: sections({}, [
section("Changes", { content: table({
columns: ["File", "Kind"],
cells: { Kind: z.enum(["add", "modify", "delete"]) },
minRows: 1,
}) }),
]) });
// a row whose Kind is "tweak" -> content/table/cell at that row's line
  • table() cells / minRows (src/core/leaves.ts)
  • per-column Zod over each row (src/core/content.ts validateTable)
  • content/table/cell pinned via rowPos(i)