{
  "title": "id-document",
  "type": "object",
  "$id": "id-document",
  "version": 1,
  "description": "id document v1 schema",
  "definitions": {
    "DID": {
      "type": "string",
      "format": "regex",
      "pattern": "^did:[a-z0-9]+:[A-Za-z0-9._:?=&%;-]+$"
    },
    "MultiLingualString": {
      "type": "object",
      "properties": {
        "localized": {
          "type": "object",
          "propertyNames": {
            "pattern": "^[a-z]{2}_[A-Z]{2}$"
          },
          "additionalProperties": {
            "type": "string"
          }
        },
        "preferredLocale": {
          "type": "object",
          "properties": {
            "country": {
              "type": "string",
              "format": "regex",
              "pattern": "^[A-Z]{2}$"
            },
            "language": {
              "type": "string",
              "format": "regex",
              "pattern": "^[a-z]{2}$"
            }
          }
        }
      },
      "additionalProperties": false,
      "format": "regex",
      "pattern": "^[a-zA-Z0-9\\s]*$",
      "maxLength": 64,
      "required": [
        "localized"
      ]
    },
    "Date": {
      "type": "object",
      "properties": {
        "day": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31
        },
        "month": {
          "type": "integer",
          "minimum": 1,
          "maximum": 12
        },
        "year": {
          "type": "integer",
          "minimum": 1950
        }
      },
      "additionalProperties": false
    },
    "Location": {
      "type": "object",
      "properties": {
        "countryCode": {
          "type": "string",
          "pattern": "^[A-Z]{2}$",
          "description": "An uppercase two-letter country code as defined by [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)"
        },
        "regionCode": {
          "type": "string",
          "format": "regex",
          "pattern": "^[A-Za-z0-9]{1,3}$",
          "description": "An uppercase region code as defined by [ISO-3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)"
        }
      }
    },
    "Address": {
      "type": "object",
      "properties": {
        "line1": {
          "type": "string",
          "format": "regex",
          "pattern": "^[a-zA-Z0-9\\s]*$",
          "maxLength": 64
        },
        "line2": {
          "type": "string",
          "format": "regex",
          "pattern": "^[a-zA-Z0-9\\s]*$",
          "maxLength": 64
        },
        "line3": {
          "type": "string",
          "format": "regex",
          "pattern": "^[a-zA-Z0-9\\s]*$",
          "maxLength": 64
        },
        "regionCode": {
          "type": "string",
          "format": "regex",
          "pattern": "^[A-Za-z0-9]{1,3}$",
          "description": "An uppercase region code as defined by [ISO-3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)"
        },
        "countryCode": {
          "type": "string",
          "format": "regex",
          "pattern": "^[A-Z]{2}$",
          "description": "An uppercase two-letter country code as defined by [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)"
        },
        "postcode": {
          "type": "string",
          "format": "regex",
          "pattern": "^[a-zA-Z0-9\\s]*$",
          "maxLength": 64
        }
      }
    }
  },
  "properties": {
    "kind": {
      "type": "string",
      "description": "DriversLicense, IdCard, SSN, NI Number, etc"
    },
    "authority": {
      "$ref": "#/definitions/MultiLingualString",
      "description": "name of the issuing authority"
    },
    "authorityId": {
      "type": "string",
      "description": "DID id of the issuing authority"
    },
    "location": {
      "$ref": "#/definitions/Location"
    },
    "identityNumber": {
      "type": "string",
      "description": "The id number of the identity credential"
    },
    "firstName": {
      "$ref": "#/definitions/MultiLingualString"
    },
    "lastName": {
      "$ref": "#/definitions/MultiLingualString"
    },
    "middleNames": {
      "$ref": "#/definitions/MultiLingualString"
    },
    "address": {
      "$ref": "#/definitions/Address"
    },
    "dob": {
      "$ref": "#/definitions/Date"
    }
  },
  "required": [
    "kind",
    "identityNumber",
    "authority",
    "firstName"
  ]
}