json_schema_passes
Validate every JSON / YAML / TOML / XML / dotenv / properties / INI / HCL file in paths against a JSON Schema document. Targets coerce through serde into the same serde_json::Value tree the schema sees, so a JSON-format schema can validate a YAML config (Kubernetes manifests, GitHub Actions workflows, Helm values.schema.json) or a TOML manifest (Cargo.toml, pyproject.toml) without separate schemas per format. The schema is loaded + compiled lazily on first evaluation and cached on the rule. Note the stringly-typed formats (XML, dotenv, .properties, INI): every value is a string, so a schema field must be typed string (with a pattern) — a type: integer / boolean / number assertion always fails against them. JSON / YAML / TOML / HCL keep native types.
Each schema-validation error becomes one violation, with the failing instance path and the schema’s error description in the message. A target that fails to parse produces a single parse-error violation, not a flood of schema errors against junk. Format is detected from the target’s extension (.json / .yaml / .yml / .toml / .properties / .ini / .cfg / .hcl / .tf / .tfvars / .nomad / .xml and the .csproj / .props / .targets family), or by filename for the .env family; pass format: to override.
Check-only — fixing schema violations is a “the user knows what value belongs there” problem, not alint’s.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
format | one of json | yaml | yml | toml | xml | dotenv | properties | ini | hcl | Override the auto-detected target format. When omitted, format is inferred from each target file’s extension (.json / .yaml / .yml / .toml / .properties / .ini / .cfg / .hcl / .tf / .tfvars / .nomad / .xml and the .csproj / .props / .targets XML family), or by filename for the .env family. | ||
schema_path | string | yes | Path to a JSON Schema file relative to the lint root. The schema must itself be JSON even when validating YAML / TOML targets. |
Plus the common paths, level, id, and when fields. This table is generated from the JSON Schema; option types and defaults are authoritative.
Example
Section titled “Example”A package.json that violates its JSON Schema
Section titled “A package.json that violates its JSON Schema”The rule fires on this repository:
package.jsonschemas/schemas/package.schema.json{ "name": "demo", "version": "v1.x"}{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "required": ["name", "version"], "properties": { "name": {"type": "string"}, "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"} }}With this .alint.yml:
version: 1rules: - id: package-conforms kind: json_schema_passes paths: "package.json" schema_path: "schemas/package.schema.json" level: erroralint check reports:
--- package.json --------------------------------------------------------------- x error package-conforms schema violation at `/version`: "v1.x" does not match "^[0-9]+\.[0-9]+\.[0-9]+$"
Summary (1 violation): x 1 error 0 passing * 1 failingA .csproj auto-detected as XML that violates its JSON Schema
Section titled “A .csproj auto-detected as XML that violates its JSON Schema”The rule fires on this repository:
App.csprojschemas/schemas/project.schema.json<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>banana</TargetFramework> </PropertyGroup></Project>{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "required": ["Project"], "properties": { "Project": { "type": "object", "required": ["@Sdk", "PropertyGroup"], "properties": { "@Sdk": {"type": "string"}, "PropertyGroup": { "type": "object", "required": ["TargetFramework"], "properties": { "TargetFramework": {"type": "string", "pattern": "^net[0-9]+\\.[0-9]+$"} } } } } }}With this .alint.yml:
version: 1rules: - id: csproj-conforms kind: json_schema_passes paths: "App.csproj" schema_path: "schemas/project.schema.json" level: erroralint check reports:
--- App.csproj ----------------------------------------------------------------- x error csproj-conforms schema violation at `/Project/PropertyGroup/TargetFramework`: "banana" does not match "^net[0-9]+\.[0-9]+$"
Summary (1 violation): x 1 error 0 passing * 1 failingA package.json that conforms to its JSON Schema
Section titled “A package.json that conforms to its JSON Schema”This repository is compliant:
package.jsonschemas/schemas/package.schema.json{ "name": "demo", "version": "1.2.3"}{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "required": ["name", "version"], "properties": { "name": {"type": "string"}, "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"} }}With this .alint.yml:
version: 1rules: - id: package-conforms kind: json_schema_passes paths: "package.json" schema_path: "schemas/package.schema.json" level: erroralint check reports:
v All 1 rule(s) passed.An explicit format xml parses an .config file that conforms to the schema
Section titled “An explicit format xml parses an .config file that conforms to the schema”This repository is compliant:
app.configschemas/schemas/project.schema.json<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> </PropertyGroup></Project>{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "required": ["Project"], "properties": { "Project": { "type": "object", "required": ["@Sdk", "PropertyGroup"], "properties": { "@Sdk": {"type": "string"}, "PropertyGroup": { "type": "object", "required": ["TargetFramework"], "properties": { "TargetFramework": {"type": "string", "pattern": "^net[0-9]+\\.[0-9]+$"} } } } } }}With this .alint.yml:
version: 1rules: - id: config-conforms kind: json_schema_passes paths: "app.config" schema_path: "schemas/project.schema.json" format: xml level: erroralint check reports:
v All 1 rule(s) passed.