Skip to content

VALIDATION-PLANES-03: Constrain section order

sections({order:‘strict’}) makes out-of-order headings a positioned structure/section-order finding.

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.

const c = contract({ body: sections({ order: "strict" }, [
section("Summary"),
section("Details"),
]) });
c.validate("## Details\n\n## Summary\n", { path: "doc.md" }).findings;
// [{ id: "structure/section-order", level: "error", pos: { line: 1 }, ... }]
// (the finding pins at the out-of-order 'Details' heading on line 1)
  • sections() LevelOpts.order: 'strict' (src/core/grammar.ts)
  • structure/section-order (src/core/structure.ts checkStrict)
  • Finding.pos pinned at the out-of-order heading