Validation results

The Jsontron keywords are Ajv keywords: a failing rule set makes the validation fail, and its failures are Ajv errors in validate.errors, with those of the standard keywords. Create Ajv with allErrors: true to get the errors of every keyword rather than of the first that fails.

One error per failure

Each failing assert or report is one error:

Field Value
keyword the keyword that evaluates the rule set: rules when the schema object has it, else assert, else report
message the failure text, with its labels
instancePath the location of the instance the schema object applies to (not of the context node)
schemaPath the schema object's path followed by the keyword, such as #/properties/order/rules
params {}
const validate = ajv.compile({
  type: "object",
  properties: {
    order: {
      type: "object",
      rules: [
        {
          id: "lines",
          context: ".lines[]",
          asserts: [{ flag: "warning", test: ". > 0", message: "line \\(.) must be positive" }],
        },
      ],
    },
  },
});

validate({ order: { lines: [-1, 2, -3] } });
for (const error of validate.errors ?? [])
  console.log(`${error.instancePath} ${error.schemaPath}: ${error.message}`);
/order #/properties/order/rules: [lines][flag=warning] line -1 must be positive
/order #/properties/order/rules: [lines][flag=warning] line -3 must be positive

Evaluation errors

When a let, a context or a test raises a jq error, the rule set stops and gives one error, under the same keyword, whose message is jq evaluation error: followed by jq's error text, and whose params is { evaluationError: "<jq's error text>" } (the type JsontronEvaluationErrorParams). That text is not part of the specification, and may change between versions of jqlite.

const validate = ajv.compile({ assert: ".total > 0" });
validate([1, 2]);
console.log(validate.errors?.[0].message); // jq evaluation error: Cannot index array with string ("total")

To keep a test from failing that way on data of an unexpected type, use ?, // or try in the expression: see jq in Jsontron.