Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Module json_schema_passes

Module json_schema_passes 

Source
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_path points at a JSON Schema file relative to the lint root. Schema is loaded + compiled lazily on the first evaluate() 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); pass format: to override. YAML and TOML coerce through serde into the same serde_json::Value tree the schema validates against — same trick json_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.

Structs§

JsonSchemaPassesRule

Functions§

build