{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/normapi-com/main/json-schema/normapi-com-validation-result-schema.json",
  "title": "ValidationResult",
  "x-generated": "2026-10-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/normapi-com-validation-api-openapi.yml#/components/schemas/ValidationResult",
  "type": "object",
  "properties": {
    "acceptable": {
      "type": "boolean",
      "description": "True when no ERROR-severity finding remains. The verdict."
    },
    "rulesetVersion": {
      "type": "string"
    },
    "scenario": {
      "type": [
        "string",
        "null"
      ],
      "description": "Which profile was recognised. Null means no rules ran at all — an\nempty findings list then does not mean \"correct\".\n"
    },
    "wellFormed": {
      "type": "boolean",
      "description": "Whether the document parsed as XML at all."
    },
    "schemaValid": {
      "type": "boolean",
      "description": "Whether it satisfied the XSD for its syntax."
    },
    "schematronValid": {
      "type": "boolean",
      "description": "Whether the business rules reported nothing whatsoever. Not a\nverdict: the rule set emits advisories on perfectly valid invoices,\nand any advisory sets this false while acceptable stays true.\n"
    },
    "businessRulesEvaluated": {
      "type": "boolean",
      "description": "False when the document failed the schema first."
    },
    "findings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Finding"
      }
    }
  },
  "required": [
    "acceptable",
    "rulesetVersion",
    "wellFormed",
    "schemaValid",
    "schematronValid",
    "businessRulesEvaluated",
    "findings"
  ],
  "$defs": {
    "Explanation": {
      "type": "object",
      "properties": {
        "meaning": {
          "type": "string",
          "description": "What the rule actually requires, in ordinary language."
        },
        "cause": {
          "type": "string",
          "description": "Why an invoice typically trips it."
        },
        "fix": {
          "type": "string",
          "description": "What to change to make it pass."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Where the rule is explained on the site: its own page, with an XML\nexample for the common rules, or its entry on a rule-group page.\n"
        }
      },
      "required": [
        "meaning",
        "cause",
        "fix",
        "url"
      ]
    },
    "Finding": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "The rule identifier, e.g. BR-DE-15."
        },
        "severity": {
          "type": "string",
          "enum": [
            "ERROR",
            "WARNING",
            "INFORMATION"
          ],
          "description": "As the official XRechnung configuration sets it for the matched\nscenario, which can differ from the rule's own flag — BR-CL-23 is\nfatal as written and a warning in an XRechnung. That is how it\nmatches the verdict in `acceptable`.\n"
        },
        "origin": {
          "type": "string",
          "enum": [
            "SCHEMA",
            "SCHEMATRON"
          ]
        },
        "text": {
          "type": "string",
          "description": "The official rule text, as the rule set words it. Named `text`, not\n`message` — a client generated from an earlier revision of this file\nlooked for `message` and never found it.\n"
        },
        "location": {
          "type": [
            "string",
            "null"
          ],
          "description": "Where in the document the rule fired, in Clark notation: each step\ncarries its namespace as a `Q{…}` prefix rather than a short form\nlike `cac:`, because a prefix means nothing without the document\nthat declared it.\n"
        },
        "line": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Set for schema findings; null for Schematron ones."
        },
        "column": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Set for schema findings; null for Schematron ones."
        },
        "test": {
          "type": [
            "string",
            "null"
          ],
          "description": "The expression the validator evaluated, where it reports one."
        },
        "explanation": {
          "description": "The rule in plain language, in the language `Accept-Language`\nchose. Always present; null for schema findings (origin SCHEMA).\n",
          "anyOf": [
            {
              "$ref": "#/$defs/Explanation"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code",
        "severity",
        "origin",
        "text"
      ]
    }
  }
}