Skip to content

VALIDATION-PLANES-10: Cross into content: a one-field frontmatter schema

contract({frontmatter: z.object({…})}) runs Zod over the parsed frontmatter, line-mapping each issue to its key.

Builds on: VALIDATION-PLANES-02: The smallest contract: one required section

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

import { z } from "zod";
const c = contract({
frontmatter: z.object({ id: z.string() }),
body: sections({}, [section("Summary")]),
});
// frontmatter missing `id` -> frontmatter/required (document-level: an absent
// key has no line; lineForPath pins a *present* key's issue to its source line)
  • ContractDef.frontmatter (Zod) (src/core/grammar.ts)
  • frontmatter/required (src/core/content.ts matchFrontmatter)
  • DocTree.frontmatter.lineForPath (src/core/projection.ts)