1.3.0
JSON Schema validation in real time. Drop a companion schema file next to any .json you edit, and the plugin highlights validation errors as you type. Closes the 1.x roadmap.
Added
- JSON Schema validation via Ajv (v8). Default behavior: when you open
data.json, the plugin looks fordata.schema.jsonin the same folder; if found, every change in tree or source mode is validated against the schema. - Schema banner above the editor body shows the current error count (
"3 schema errors — hover the red rows for details"). Hidden when the document is valid; switches to a yellow "schema not loaded" variant if the schema file itself is malformed. - Inline row markers — every tree row corresponding to a validation error gets a red outline + a hover-tooltip with the human-readable message.
- Two new settings:
validateAgainstSchema(defaulttrue) — master switch.companionSchemaSuffix(default.schema.json) — change to e.g..json-schemaif your conventions differ.
- New runtime dependency:
ajv@8.
Internal
- New pure module
src/core/schema.ts—compileSchema(text)returns a discriminated union ({ok, schema}|{ok: false, error}); the compiled schema has avalidate(value): PathError[]that converts Ajv'sinstancePathJSON-Pointer to ourJsonPathsegment array (including~0/~1decoding). - New
src/obsidian/SchemaBanner.tsUI component withsetErrors(n)+setSchemaParseError(msg)+hide(). TreeView.setValidationErrors(map)adds.json-row-errorclass +titleattribute on offending rows; persists across re-renders.JsonFileViewgainssetSchema(text)(public for tests/manual) and an asynctryLoadCompanionSchema()that reads the sibling viaapp.vault.cachedReadon file open. Best-effort: silent failure if the vault is unavailable.- 33 new tests (12 schema core, 6 SchemaBanner, 5 TreeView row-marker, 6 JsonFileView integration, +4 settings extension). Total: 373 → 402.
Notes
- Bundle size:
main.jsgrows from ~37 KB to ~163 KB. The vast majority is Ajv; that is the cost of "real" JSON Schema. If you prefer the older lightweight bundle and don't need validation, turn the setting off — the validator code is still bundled but never runs. $schemaURL fetching is out of scope. The plugin treats$schemainside your data as metadata; it does not fetch remote schemas. Companion-file pattern is the canonical wire-up.