{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://thewarrecord.com/api/v1/schema/toll.json",
 "title": "toll",
 "type": "object",
 "required": [
  "id",
  "type",
  "conflict",
  "counting_body",
  "scope",
  "value",
  "citations",
  "record_state",
  "schema_version"
 ],
 "properties": {
  "record_state": {
   "enum": [
    "active",
    "merged",
    "withdrawn"
   ]
  },
  "merged_into": {
   "type": "string"
  },
  "withdrawn_reason": {
   "type": "string"
  },
  "schema_version": {
   "const": 1
  },
  "created_at": {
   "type": "string",
   "format": "date-time"
  },
  "last_changed": {
   "type": "string",
   "format": "date-time"
  },
  "id": {
   "type": "string",
   "pattern": "^to-\\d{8}-[0-9a-hjkmnp-tv-z]{4}$"
  },
  "type": {
   "const": "toll"
  },
  "conflict": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "counting_body": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "scope": {
   "type": "object",
   "required": [
    "measure",
    "population",
    "side",
    "geography",
    "period",
    "bound",
    "method",
    "as_of"
   ],
   "properties": {
    "measure": {
     "enum": [
      "killed",
      "injured",
      "casualties",
      "missing",
      "displaced",
      "detained"
     ],
     "description": "casualties = killed and injured counted together, as the body states it; never split or compared with killed."
    },
    "population": {
     "enum": [
      "civilian",
      "combatant",
      "all",
      "unknown"
     ]
    },
    "subgroup": {
     "enum": [
      "children",
      "women",
      "health_workers",
      "aid_workers",
      "journalists"
     ],
     "description": "Only this group within the population. A subgroup figure is its own scope."
    },
    "side": {
     "type": "string",
     "description": "A nationality or party slug, never a sum of sides."
    },
    "geography": {
     "type": "string"
    },
    "period": {
     "type": "object",
     "required": [
      "kind"
     ],
     "properties": {
      "kind": {
       "enum": [
        "cumulative",
        "range"
       ]
      },
      "from": {
       "type": "string",
       "format": "date"
      },
      "to": {
       "type": "string",
       "format": "date"
      }
     },
     "additionalProperties": false
    },
    "bound": {
     "enum": [
      "exact",
      "at_least",
      "estimate",
      "range"
     ]
    },
    "method": {
     "enum": [
      "individually_verified",
      "reported_by_body",
      "modelled"
     ]
    },
    "as_of": {
     "type": "string",
     "format": "date"
    }
   },
   "additionalProperties": false
  },
  "value": {
   "type": "object",
   "properties": {
    "best": {
     "type": "integer",
     "minimum": 0
    },
    "low": {
     "type": "integer",
     "minimum": 0
    },
    "high": {
     "type": "integer",
     "minimum": 0
    }
   },
   "additionalProperties": false
  },
  "note": {
   "type": "string",
   "description": "Our note on the scope, in plain words."
  },
  "supersedes": {
   "type": "string",
   "pattern": "^to-\\d{8}-[0-9a-hjkmnp-tv-z]{4}$"
  },
  "citations": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "object",
    "required": [
     "source",
     "url",
     "origin",
     "role",
     "published_at",
     "accessed_at"
    ],
    "properties": {
     "source": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
     },
     "url": {
      "type": "string",
      "format": "uri"
     },
     "archive_url": {
      "type": "string",
      "format": "uri"
     },
     "origin": {
      "type": "string",
      "minLength": 3,
      "description": "The first-hand material this citation relies on. Independence is counted on distinct origins, not outlets."
     },
     "role": {
      "enum": [
       "evidence",
       "corroboration",
       "contradiction",
       "claim_origin",
       "count",
       "visual",
       "sensor"
      ]
     },
     "supports": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "published_at": {
      "type": "string",
      "format": "date-time"
     },
     "accessed_at": {
      "type": "string",
      "format": "date-time"
     },
     "language": {
      "type": "string"
     },
     "excerpt": {
      "type": "string",
      "maxLength": 200
     }
    },
    "additionalProperties": false
   }
  }
 },
 "additionalProperties": false
}
