Skip to content

VALIDATION-PLANES-17: The same checks in code (TS-API parity)

Library predicate builders give a combinator-authored contract the same text checks the YAML compiles to.

Builds on: VALIDATION-PLANES-16: All three planes in one deterministic order

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

import { contract, sections, section, requires, forbids } from "markdown-contract";
// (planned) predicate builders — the same checks the requires:/forbids: YAML compiles to
const c = contract({
body: sections({}, [
section("Output contract", { rules: [requires([{ pattern: "DONE pr=" }])] }),
]),
rules: [forbids([{ pattern: "}scripts/", normalize: false }])], // document-level
});
// same text/requires + text/forbids findings as the YAML form
  • TS-API parity: requires() / forbids() / textRule() builders (src/core/text-constraints.ts) compiling to rule / docRule
  • text/requires + text/forbids findings (exact API named at implementation)