Schema Validation
Schema-based deliverable specs define machine-readable acceptance contracts. Use them when another workflow step or application must consume a validated JSON value.
Choosing a Kind
| Kind | Use it when |
|---|---|
ZOD_SCHEMA | Your organization authors validation in TypeScript with Zod |
JSON_SCHEMA | The same contract must work across languages and tools |
STRUCTURED_JSON | The output is JSON and the spec supplies a direct JSON contract |
Use MARKDOWN_DOCUMENT for human-readable documents and optionally select
construction guidance with templateBinding.
Zod Schema
ZOD_SCHEMA stores the authoritative Zod module source. The module must export
a schema that validates the produced value.
1curl -X POST https://deliverable-specs-api.xema.dev/deliverable-specs \
2 -H "Authorization: Bearer $TOKEN" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "slug": "requirements-schema",
6 "version": "1.0.0",
7 "title": "Requirements schema",
8 "kind": "ZOD_SCHEMA",
9 "category": "requirements",
10 "zodSchemaSource": "import { z } from '\''zod'\'';\nexport const schema = z.object({ projectName: z.string().min(1), requirements: z.array(z.string()).min(1) });"
11 }'JSON Schema
JSON_SCHEMA stores a JSON Schema document as JSON text. It is the portable
choice when producers and consumers use different languages.
1curl -X POST https://deliverable-specs-api.xema.dev/deliverable-specs \
2 -H "Authorization: Bearer $TOKEN" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "slug": "risk-assessment",
6 "version": "1.0.0",
7 "title": "Risk assessment",
8 "kind": "JSON_SCHEMA",
9 "category": "risk",
10 "content": "{\"type\":\"object\",\"additionalProperties\":false,\"required\":[\"level\",\"summary\"],\"properties\":{\"level\":{\"enum\":[\"low\",\"medium\",\"high\"]},\"summary\":{\"type\":\"string\",\"minLength\":1}}}"
11 }'Inference Enforcement
For a supported single-JSON-document contract, set
rules.enforceViaInference: true to validate structured output as it is
produced as well as at the harvested-file boundary. This does not replace final
deliverable validation.
Failure Behaviour
Malformed schema source, an unsupported body for the selected kind, and output that fails the contract are explicit errors. Xema does not reinterpret invalid JSON as a document or silently switch to a different spec kind.
Previous: ← Document Templates
Next: Overlays →