Skip to main content

Module format

Module format 

Source
Expand description

Built-in well-formedness checks for common output formats.

These answer one question: is the submission actually the format it claims to be? They do not answer “does it have the right shape”, which is JSON Schema’s job (for JSON) or an agent’s own Rhai validator’s job (for anything else).

The distinction is the whole reason this module is small. Checking that a document parses is one call into a parser. Checking that it matches an XSD, a JSON Schema, or a GraphQL schema means owning that format’s schema language, which is exactly the per-format weight the output system is built to avoid.

What this catches is the failure that actually happens: the model wraps its answer in ``` fences, adds a sentence of preamble, or hands back JSON when the stage asked for XML. All three are a parse error, and all three are worth bouncing back for a retry.

A format with no entry here validates nothing, which is the honest outcome: the label is opaque by design, and most labels are not formats this crate has ever heard of.

Constants§

BUILTIN_FORMATS
Every format this crate can check, for documentation and diagnostics.

Functions§

check
Check content against the built-in for format.
has_builtin
Whether a built-in check exists for format.