{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "GRID Registrar Metadata Schema",
  "$comment": "Unified schema for the Global Registrar Information Directory (GRID).",
  "type": "object",
  "required": [
    "UN_member_state",
    "registrar_full_name",
    "registrar_identifier_code",
    "register_name",
    "register_type",
    "legal_basis",
    "authoritative_body",
    "register_id",
    "registered_id_pattern"
  ],
  "properties": {
    "UN_member_state": {
      "type": "string",
      "pattern": "^[A-Z]{2}$",
      "description": "The ISO 3166-1 alpha-2 code (e.g., AU, ES, CA)."
    },
    "subdivision_code": {
      "type": ["string", "null"],
      "pattern": "^[A-Z0-9]{1,3}$",
      "description": "ISO 3166-2 code. Use null if no subdivision exists."
    },
    "registrar_full_name": {
      "type": "string",
      "description": "Official administrative name of the organization."
    },
    "registrar_identifier_code": {
      "type": "string",
      "description": "ECCMA acronym (e.g., ASIC, BER)."
    },
    "register_name": {
      "type": "string",
      "description": "Specific register dataset name."
    },
    "register_type": {
      "type": "string",
      "enum": ["Organisation", "Land", "Vessel", "Professional", "Individual"],
      "description": "Classification of the recorded entities."
    },
    "legal_basis": {
      "type": "string",
      "format": "uri",
      "description": "Link to the legislative mandate."
    },
    "authoritative_body": {
      "type": "string",
      "format": "uri",
      "description": "Link to the oversight Ministry/Department."
    },
    "register_id": {
      "type": "string",
      "description": "ISO 8000-116 ALEI Prefix (e.g., CA-BC.BER)."
    },
    "registered_id_pattern": {
      "type": "string",
      "description": "URI template for member identifiers."
    },
    "registrar_notes": {
      "type": ["string", "null"],
      "description": "Optional commentary provided by the registrar regarding this entry.",
      "$comment": "Added to provide a legitimate location for registrar-specific metadata/notes."
    },
    "query_endpoint": { "type": ["string", "null"] },
    "resolver_endpoint": { "type": ["string", "null"], "format": "uri" },
    "did": { "type": ["string", "null"] },
    "grid_reference": { "type": ["string", "null"], "format": "uri" }
  }
}