Skip to content

VALIDATION-PLANES-05: Allow interchangeable headings with oneOf

oneOf([…]) accepts any one of several spellings at a single position as one logical slot.

Builds on: VALIDATION-PLANES-03: Constrain section order

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

import { oneOf } from "markdown-contract";
const c = contract({ body: sections({ order: "strict" }, [
oneOf(["Summary", "Overview"]), // either heading fills the slot
section("Details"),
]) });
// "## Overview" then "## Details" validates clean
  • oneOf() / OneOfSpec (src/core/grammar.ts)
  • one slot, multiple accepted names (src/core/structure.ts slotsOf)