{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openfreytprotocol.example/schemas/v0/area",
  "title": "Area",
  "description": "A geographic area represented by at least one of: UN/LOCODE, ISO 3166-2 administrative region code, or a GeoJSON Polygon/MultiPolygon.",
  "type": "object",
  "properties": {
    "locode": {
      "type": "string",
      "description": "UN/LOCODE (e.g. NLRTM for Rotterdam).",
      "pattern": "^[A-Z]{2}[A-Z2-9]{3}$"
    },
    "adminRegionCode": {
      "type": "string",
      "description": "ISO 3166-2 administrative region code (e.g. NL-ZH).",
      "pattern": "^[A-Z]{2}-[A-Z0-9]{1,3}$"
    },
    "geoJson": {
      "type": "object",
      "description": "GeoJSON RFC 7946 Polygon or MultiPolygon.",
      "required": ["type", "coordinates"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["Polygon", "MultiPolygon"]
        },
        "coordinates": {
          "type": "array"
        }
      }
    }
  }
}
