Expand description
json_schema_passes — assert that a set of JSON / YAML /
TOML files validates against a JSON Schema.
Closes the last unshipped structured-query primitive
(json_path_* shipped in v0.4.4). JSON Schema sees use far
beyond JSON itself: many YAML configs (Kubernetes, GitHub
Actions workflows, Helm chart values.schema.json) carry a
schema, and TOML manifests (Cargo, pyproject) increasingly
ship one too. This rule lets a project enforce its own
schemas alongside upstream-supplied ones.
§Behaviour
schema_pathpoints at a JSON Schema file relative to the lint root. Schema is loaded + compiled lazily on the firstevaluate()call and cached on the rule struct (OnceLock); a malformed schema produces one repository-level violation rather than one violation per target file.- The target’s format is auto-detected from its extension
(
.json/.yaml/.yml/.toml); passformat:to override. YAML and TOML coerce through serde into the sameserde_json::Valuetree the schema validates against — same trickjson_path_*uses. - Each schema-validation error becomes one violation, with the message including the failing instance path and the schema’s error description. A target that fails to parse produces one parse-error violation, not a flood of schema errors against junk.
Check-only — fixing schema violations is a “the user knows what value belongs there” problem, not alint’s.