{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://otvs.org/schemas/1.0/validation-event.json",
  "title": "OTVS 1.0 Validation Event",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "validationId",
    "ticketId",
    "eventId",
    "gateId",
    "deviceId",
    "direction",
    "occurredAt",
    "decision",
    "mode",
    "countedUse"
  ],
  "properties": {
    "validationId": {
      "$ref": "#/$defs/uuid"
    },
    "ticketId": {
      "$ref": "#/$defs/uuid"
    },
    "entitlementId": {
      "type": [
        "string",
        "null"
      ]
    },
    "eventId": {
      "type": "string",
      "minLength": 1
    },
    "gateId": {
      "type": "string",
      "minLength": 1
    },
    "gateType": {
      "enum": [
        "PERIMETER",
        "ZONE",
        "EXIT"
      ]
    },
    "deviceId": {
      "type": "string",
      "minLength": 1
    },
    "direction": {
      "enum": [
        "IN",
        "OUT"
      ]
    },
    "occurredAt": {
      "type": "string",
      "format": "date-time"
    },
    "decision": {
      "enum": [
        "ALLOW",
        "REJECT"
      ]
    },
    "reasonCode": {
      "type": [
        "string",
        "null"
      ]
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "mode": {
      "enum": [
        "ONLINE",
        "OFFLINE"
      ]
    },
    "countedUse": {
      "type": "boolean"
    },
    "requirementResults": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "satisfied"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "satisfied": {
            "type": "boolean"
          },
          "method": {
            "type": "string"
          }
        }
      }
    },
    "prevEventHash": {
      "type": [
        "string",
        "null"
      ]
    },
    "ext": {
      "type": "object"
    }
  },
  "$defs": {
    "uuid": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    }
  }
}
