{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schema.traceoriginal.com/trace-original-proof-of-ownership-sv-schema-v1.0.json",
  "title": "trace:original Proof of Ownership Schema v1.0",
  "type": "object",
  "definitions": {
    "Hex64": {
      "type": "string",
      "pattern": "^([a-f]|\\d){64}$"
    },
    "ISO8601-Date": {
      "type": "string",
      "pattern": "^20(19|[2-9]\\d)-(0\\d|1[0-2])-([0-2]\\d|30|31)T([0-1]\\d|2[0-3])(:[0-5]\\d){2}\\.\\d{3}Z$"
    },
    "Base64": {
      "type": "string",
      "pattern": "^[A-Za-z0-9/+]*={0,2}$"
    },
    "VersionType": {
      "type": "object",
      "properties": {
        "Schema": {
          "type": "string",
          "pattern": "https://.*"
        }
      },
      "required": [
        "Schema"
      ],
      "additionalProperties": false
    },
    "Url": {
      "type": "string",
      "pattern": "^((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[\\-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9\\.\\-]+|(?:www\\.|[\\-;:&=\\+\\$,\\w]+@)[A-Za-z0-9\\.\\-]+)((?:\\/[\\+~%\\/\\.\\w\\-_]*)?\\??(?:[\\-\\+=&;%@\\.\\w_]*)#?(?:[\\.\\!\\/\\\\\\w]*))?)?"
    }
  },
  "properties": {
    "Version": {
      "$ref": "#/definitions/VersionType"
    },
    "Content": {
      "type": "object",
      "properties": {
        "Kommentar": {
          "type": "string"
        },
        "TraceOriginalId": {
          "$ref": "#/definitions/Hex64"
        },
        "Liggare": {
          "$ref": "#/definitions/Url"
        },
        "Tidsstämpel": {
          "$ref": "#/definitions/ISO8601-Date"
        },
        "Ägare": {
          "type": "object",
          "properties": {
            "ID": {
              "type": ["string", "number"]
            },
            "ID Typ": {
              "enum": [
                "VAT identifikationsnummer",
                "Svenskt personnummer",
                "Svenskt organisationsnummer",
                "Mobilnummer",
                "E-post",
                "BIC",
                "LEI",
                "ZealiD"
              ]
            },
            "Namn": {
              "type": "string"
            },
            "Email": {
              "type": "string"
            },
            "Telefon": {
              "type": "string"
            },
            "Adress": {
              "type": "object",
              "properties": {
                "Gata": {
                  "type": "string"
                },
                "Stad": {
                  "type": "string"
                },
                "Postnummer": {
                  "type": [
                    "string",
                    "number"
                  ]
                },
                "Land": {
                  "type": "string"
                }
              }
            },
            "Liggare": {
              "type": "string"
            }
          },
          "required": [
            "Namn",
            "Email",
            "ID",
            "ID Typ"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "Kommentar",
        "TraceOriginalId",
        "Tidsstämpel",
        "Ägare"
      ],
      "additionalProperties": false
    },
    "TechnicalDetails": {
      "type": "object",
      "properties": {
        "ContentHash": {
          "$ref": "#/definitions/Hex64"
        },
        "DocumentHash": {
          "$ref": "#/definitions/Hex64"
        },
        "OwnerSignature": {
          "$ref": "#/definitions/Base64"
        },
        "OwnerSignedData": {
          "$ref": "#/definitions/Base64"
        }
      },
      "required": [
        "ContentHash",
        "DocumentHash",
        "OwnerSignature"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "Version",
    "Content",
    "TechnicalDetails"
  ],
  "additionalProperties": false
}
