{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://www.schemastore.org/jsontron-0.2.json", "$defs": { "assertion": { "type": "object", "required": ["test"], "additionalProperties": false, "properties": { "test": { "type": "string", "minLength": 1 }, "message": { "type": "string" }, "id": { "type": "string", "minLength": 1, "description": "Optional human-readable identifier prefixed to the failure message as [id]." }, "flag": { "type": "string", "minLength": 1, "description": "Optional severity label (e.g. 'error', 'warning', 'info') prefixed to the failure message as [flag=value]." }, "role": { "type": "string", "minLength": 1, "description": "Alias of 'flag' for Schematron parity. Mutually exclusive with 'flag' (enforced at build time)." } } }, "sugar": { "oneOf": [ { "type": "string", "minLength": 1, "description": "Shorthand: test and message source are this jq expression." }, { "$ref": "#/$defs/assertion" }, { "type": "array", "minItems": 1, "items": { "oneOf": [ { "type": "string", "minLength": 1 }, { "$ref": "#/$defs/assertion" } ] } } ] }, "let": { "type": "object", "minProperties": 1, "description": "Object mapping variable names (matching [A-Za-z_][A-Za-z0-9_]*, excluding the reserved 'root') to jq expressions. Entries are evaluated in document order; each takes the first value of its expression (or null if the stream is empty).", "propertyNames": { "pattern": "^(?!root$)[A-Za-z_][A-Za-z0-9_]*$" }, "additionalProperties": { "type": "string", "minLength": 1 } } }, "title": "Jsontron 0.2", "description": "Jsontron vocabulary: Schematron-like rules, assert, report, and let keywords with id/flag/role metadata, over JSON Schema, using jq expressions.", "type": "object", "properties": { "rules": { "type": "array", "minItems": 1, "description": "Array of rules. Each rule selects context nodes with a jq expression and runs asserts and/or reports.", "items": { "type": "object", "required": ["context"], "additionalProperties": false, "properties": { "context": { "type": "string", "minLength": 1, "description": "jq expression evaluated against the current instance; each result is a context node." }, "id": { "type": "string", "minLength": 1, "description": "Optional human-readable identifier prefixed to every failure message produced by this rule as [id]." }, "let": { "$ref": "#/$defs/let" }, "asserts": { "type": "array", "minItems": 1, "description": "Assertions that FAIL when the test is not jq-truthy (classic Schematron assert).", "items": { "$ref": "#/$defs/assertion" } }, "reports": { "type": "array", "minItems": 1, "description": "Assertions that FAIL when the test IS jq-truthy (classic Schematron report).", "items": { "$ref": "#/$defs/assertion" } } }, "anyOf": [ { "required": ["asserts"], "properties": { "asserts": {} } }, { "required": ["reports"], "properties": { "reports": {} } } ] } }, "assert": { "$ref": "#/$defs/sugar", "description": "Sugar for a rule with context \".\". String, object, or array of those; all append to one context=\".\" rule. Fails when the test is not jq-truthy." }, "report": { "$ref": "#/$defs/sugar", "description": "Sugar for a rule with context \".\" whose test polarity is inverted (Schematron report). Fails when the test IS jq-truthy." }, "let": { "$ref": "#/$defs/let", "description": "Schema-level let bindings in scope for every rule at this schema location, alongside $root." } } }