{
  "title": "ID document",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://velocitynetwork.foundation/schemas/id-document-v1.0",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "@context": {
      "$ref": "#/definitions/Json-ld-context_Schema"
    },
    "type": {
      "type": "string",
      "default": "IdDocument"
    },
    "documentType": {
      "type": "string",
      "description": "The type of document.",
      "maxLength": 32
    },
    "authority": {
      "$ref": "#/definitions/Organization_Schema"
    },
    "validity": {
      "$ref": "#/definitions/Validity_Schema"
    },
    "person": {
      "$ref": "#/definitions/Person_Schema"
    },
    "identifier": {
      "type": "string",
      "description": "The id number.",
      "maxLength": 64
    },
    "nationality": {
      "type": "string",
      "pattern": "^[A-Z]{2}$",
      "description": "The nationality of the person holding the document.",
      "maxLength": 2
    },
    "postalAddress": {
      "$ref": "#/definitions/Address_Schema"
    }
  },
  "required": [
    "documentType",
    "authority",
    "identifier",
    "person"
  ],
  "definitions": {
    "Json-ld-context_Schema": {
      "title": "json-ld-context",
      "oneOf": [
        {
          "type": "string",
          "maxLength": 2048
        },
        {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "maxLength": 2048
          }
        }
      ],
      "description": "Simplified context for Velocity Publishers to Use"
    },
    "Address_Schema": {
      "title": "Address",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "default": "Address"
        },
        "streetAddress": {
          "type": "string",
          "description": "The street address.",
          "maxLength": 512
        },
        "addressLocality": {
          "type": "string",
          "description": "The locality of the address, e.g., town or city name.",
          "maxLength": 256
        },
        "addressRegion": {
          "type": "string",
          "pattern": "^[A-Z]{2}(-[A-Z0-9]{1,3})?$",
          "description": "The region where the place is. These are states, provinces, etc. Must be an [ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2)",
          "maxLength": 6
        },
        "postCode": {
          "type": "string",
          "description": "Postcode or zip code of the address.",
          "maxLength": 32
        },
        "addressCountry": {
          "type": "string",
          "description": "The country where the place is. Must be an [ISO 3166 2 letter country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)",
          "pattern": "^[A-Z]{2}$",
          "maxLength": 2
        }
      },
      "required": [
        "addressCountry"
      ]
    },
    "Did_Schema": {
      "title": "DID",
      "type": "string",
      "pattern": "^did:[a-z0-9]+:[A-Za-z0-9._:?=&%;-]+$"
    },
    "Organization_Schema": {
      "title": "Organization",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "default": "Organization"
        },
        "name": {
          "type": "string",
          "description": "The name of the organization.",
          "maxLength": 256
        },
        "identifier": {
          "$ref": "#/definitions/Did_Schema"
        },
        "place": {
          "$ref": "#/definitions/Place_Schema"
        }
      },
      "required": [
        "name",
        "place"
      ]
    },
    "Person_Schema": {
      "title": "Person",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "default": "Person"
        },
        "givenName": {
          "type": "string",
          "description": "The given name or first name of the person.",
          "maxLength": 64
        },
        "familyName": {
          "type": "string",
          "description": "The family name or surname of the person.",
          "maxLength": 64
        },
        "middleName": {
          "type": "string",
          "description": "The middle name of the person.",
          "maxLength": 256
        },
        "namePrefix": {
          "type": "string",
          "description": "A prefix to the name such as Dr or Sir.",
          "maxLength": 8
        },
        "nameSuffix": {
          "type": "string",
          "description": "A suffix to the name such as Jr. or Sr.",
          "maxLength": 16
        },
        "birthDate": {
          "type": "string",
          "format": "date",
          "description": "The date of birth of the person."
        },
        "birthPlace": {
          "$ref": "#/definitions/Place_Schema"
        },
        "gender": {
          "type": "string",
          "enum": [
            "Male",
            "Female",
            "Other"
          ],
          "description": "The gender of the person."
        }
      },
      "required": [
        "givenName",
        "birthDate"
      ]
    },
    "Place_Schema": {
      "title": "Place",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "default": "Place"
        },
        "name": {
          "type": "string",
          "description": "The name of the place, e.g., building name, branch name, etc.",
          "maxLength": 256
        },
        "addressLocality": {
          "type": "string",
          "description": "The locality where the place is, e.g., town or city name.",
          "maxLength": 256
        },
        "addressRegion": {
          "type": "string",
          "pattern": "^[A-Z]{2}(-[A-Z0-9]{1,3})?$",
          "description": "The region where the place is. These are states, provinces, etc. Must be an [ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2)",
          "maxLength": 6
        },
        "addressCountry": {
          "type": "string",
          "description": "The country where the place is. Must be an [ISO 3166 2 letter country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)",
          "pattern": "^[A-Z]{2}$",
          "maxLength": 2
        }
      },
      "required": [
        "addressCountry"
      ]
    },
    "Validity_Schema": {
      "title": "Validity",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "default": "Validity"
        },
        "firstValidFrom": {
          "type": "string",
          "format": "date",
          "description": "The original date from which a certification, document or license is valid. "
        },
        "validFrom": {
          "oneOf": [
            {
              "format": "date"
            },
            {
              "format": "date-time"
            }
          ],
          "description": "The date from which a certification, document or license is valid. In case of renewal, validFrom date will state the date or renewal. ",
          "type": "string"
        },
        "validUntil": {
          "oneOf": [
            {
              "format": "date"
            },
            {
              "format": "date-time"
            }
          ],
          "description": "The date until which a certification, document or license is valid. ",
          "type": "string"
        },
        "validIn": {
          "$ref": "#/definitions/Place_Schema"
        }
      }
    }
  }
}