validateLast updated on
Last updated on
Validate artifacts against schemas
Validates an OpenForm artifact against the core schema.
Usage
ofm validate <artifact> [options]Arguments
| Argument | Description |
|---|---|
artifact | Artifact file (JSON/YAML) or - for stdin |
Options
| Option | Description |
|---|---|
--json | Output machine-readable JSON result |
--silent | Suppress console output (exit code only) |
--expect-kind <kind> | Assert artifact kind: form, document, checklist, bundle |
--schema-only | Only validate artifact schema (skip layer and content reference checks) |
--layers-only | Only validate layers (paths + checksums) |
--checksum-only | Only verify layer checksums |
The scope flags (--schema-only, --layers-only, --checksum-only) are mutually exclusive.
Description
The validate command parses an artifact file and runs up to three validation phases:
- Schema — checks the artifact structure against the OpenForm schema
- Layers — for file-backed layers, checks file existence and verifies checksums
- Content references — for file-backed
instructionsandagentInstructions, checks file existence and verifies checksums
Content reference validation runs automatically for any artifact kind that has instructions or agentInstructions set with kind: "file". It is skipped by --schema-only and when reading from stdin (no file context).
The command exits with code 0 if valid (warnings are allowed), 1 if any errors are found.
Examples
Validate an artifact:
ofm validate my-form.yamlValidate from stdin:
cat my-form.yaml | ofm validate -Assert expected kind:
ofm validate my-form.yaml --expect-kind formSchema only (skip file checks):
ofm validate my-form.yaml --schema-onlyGet JSON output:
ofm validate my-form.yaml --jsonSilent mode (for scripts):
ofm validate my-form.yaml --silent && echo "Valid"Output
When valid:
✓ Schema
Kind: form
Name: lease-agreement
Version: 1.0.0
Source: lease-agreement.yaml
Layers:
✓ pdf [file, application/pdf]
path: ./lease-template.pdf
file: found
checksum: verified
Content References:
⚠ instructions [file, text/markdown]
path: ./instructions.md
file: found
checksum: not set
✓ Valid (1 warning)When invalid:
✗ Schema validation failed:
✗ fields.rent: Expected type "object" but received "string"
✗ version: Required field missing
✗ Validation failedJSON output
The JSON output includes layers and contentRefs arrays when present:
{
"ok": true,
"source": "my-form.yaml",
"artifact": {
"name": "lease-agreement",
"kind": "form",
"version": "1.0.0"
},
"errors": [],
"warnings": [
{
"message": "No checksum set. Run `ofm fix` to add one.",
"path": ["instructions", "checksum"]
}
],
"layers": [
{
"key": "pdf",
"kind": "file",
"mimeType": "application/pdf",
"path": "./lease-template.pdf",
"fileExists": true,
"checksumMatch": true,
"ok": true
}
],
"contentRefs": [
{
"field": "instructions",
"kind": "file",
"mimeType": "text/markdown",
"path": "./instructions.md",
"fileExists": true,
"ok": true
}
]
}