{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://qazpolit.com/contracts/qazpolit-evidence-receipt-v1.schema.json",
  "title": "QazPolit public evidence receipt",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "kind", "evidence_state", "source", "capture", "locator"],
  "properties": {
    "schema": { "const": "qazpolit.evidence-receipt.v1" },
    "kind": { "type": "string", "minLength": 1, "maxLength": 80 },
    "evidence_state": {
      "type": "string",
      "enum": ["verified", "sourced", "archival", "compiled", "unlinked"]
    },
    "source": { "$ref": "#/$defs/source" },
    "capture": {
      "anyOf": [{ "$ref": "#/$defs/capture" }, { "type": "null" }]
    },
    "locator": { "type": ["string", "null"], "maxLength": 255 }
  },
  "$defs": {
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["url", "title", "publisher", "published_date", "archive_url"],
      "properties": {
        "url": { "type": "string", "format": "uri", "minLength": 1 },
        "title": { "type": ["string", "null"], "maxLength": 500 },
        "publisher": { "type": ["string", "null"], "maxLength": 255 },
        "published_date": { "type": ["string", "null"], "maxLength": 50 },
        "archive_url": { "type": ["string", "null"], "format": "uri" }
      }
    },
    "capture": {
      "type": "object",
      "additionalProperties": false,
      "required": ["captured_at", "checksum", "archive_url"],
      "properties": {
        "captured_at": { "type": ["string", "null"], "format": "date-time" },
        "checksum": { "type": ["string", "null"], "maxLength": 128 },
        "archive_url": { "type": ["string", "null"], "format": "uri" }
      }
    }
  }
}
