{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agrodt.github.io/agrotool-knowledge-portal/schemas/v1/organizations.schema.json",
  "title": "PublicOrganizations",
  "type": "array",
  "items": {
    "type": "object",
    "allOf": [
      { "$ref": "common.schema.json#/$defs/recordMetadata" },
      {
        "type": "object",
        "required": [
          "organization_id",
          "names",
          "aliases",
          "organization_type",
          "status",
          "source_ids"
        ],
        "properties": {
          "organization_id": {
            "type": "string",
            "pattern": "^O[A-Z0-9_-]{3,63}$"
          },
          "names": { "$ref": "common.schema.json#/$defs/localizedText" },
          "aliases": {
            "type": "array",
            "items": { "type": "string" },
            "uniqueItems": true
          },
          "organization_type": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "country": { "type": ["string", "null"] },
          "location": { "type": ["string", "null"] },
          "predecessor_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^O[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "successor_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^O[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "status": { "enum": ["verified", "provisional"] },
          "period": { "$ref": "common.schema.json#/$defs/period" },
          "source_ids": { "$ref": "common.schema.json#/$defs/sourceIds" }
        }
      }
    ],
    "unevaluatedProperties": false
  }
}
