{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://data.publicinformation.ie/schemas/transport-policies.schema.json",
  "title": "Transport Policy",
  "description": "One row of transport-policies.csv after CSVW parsing: `source_urls` and `doc_slugs` are split on `|`, and `has_document` is a boolean.",
  "type": "object",
  "additionalProperties": false,
  "required": ["policy_id", "title", "kind", "issuing_authority", "horizon", "scope", "linkages", "source_urls", "has_document", "doc_slugs"],
  "properties": {
    "policy_id": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "description": "Permanent public identifier: slugified title."},
    "title": {"type": "string", "minLength": 1},
    "kind": {"enum": ["policy", "code-of-practice"]},
    "issuing_authority": {"type": "string", "minLength": 1},
    "horizon": {"type": "string", "minLength": 1},
    "scope": {"type": "string", "minLength": 1},
    "linkages": {"type": "string", "minLength": 1},
    "source_urls": {"type": "array", "minItems": 1, "items": {"type": "string", "pattern": "^https?://"}},
    "has_document": {"type": "boolean"},
    "doc_slugs": {"type": "array", "items": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"}}
  },
  "allOf": [
    {
      "if": {"properties": {"has_document": {"const": true}}},
      "then": {"properties": {"doc_slugs": {"minItems": 1}}},
      "else": {"properties": {"doc_slugs": {"maxItems": 0}}}
    }
  ]
}
