Output Validator
A model's JSON checked against its schema, with each problem on its field.
PROGet Output Validator and 168 other Pro components with pro lifetime — Get Pro
- Category
- RAG & Evals
- Access
- ProPro · unlocked
- Source
- 565 lines · one file
- States
- 6 drawn
- Added
- 12 Oct 2026
The decision inside it
Not valid JSON and not valid against the schema are different
A parse error shows the raw text and never a pretend tree; a schema error shows the parsed tree with the wrong fields marked.
When to use it
Use Output Validator to check a model's structured (JSON) output: valid or not, every problem with its path, the raw and formatted output, and a "request correction" action. validateOutput(raw, schema) builds the result for you.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Output Validator for this.
Install it: npx shadcn@latest add @liro/output-validator
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/output-validator.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { OutputValidator, validateOutput, type SchemaField } from "@/components/ui/output-validator";
const schema: SchemaField[] = [
{ path: "customer", type: "string", required: true },
{ path: "amount", type: "number", required: true },
];
export function CheckOutput({ raw, askAgain }: { raw: string; askAgain: () => Promise<void> }) {
return <OutputValidator result={validateOutput(raw, schema, "Invoice")} schema={schema} onRequestCorrection={askAgain} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
result | StructuredOutputResult | Yes | Your own validation result, or `validateOutput(raw, schema)` from this file. |
schema | SchemaField[] | No | The fields the output should have, for the schema summary. |
onIssueSelect | (issue: ValidationIssue) => void | No | – |
onCopyRaw | () => void | No | – |
onCopyFormatted | () => void | No | – |
onRequestCorrection | () => void | Promise<void> | No | Adds "Ask for a correction". May return a promise. |
isCorrecting | boolean | No | A correction is being made, if you track it yourself. |
correction | StructuredOutputResult | No | The corrected output, once you have it: shown beside the original. |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themebadgebuttonsegmented-controltabsStates
All of them are drawn by the component. None is left for you to design.
- Valid
- Wrong fields
- Problem selected
- Not valid JSON
- Correcting
- Corrected
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances