{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://magmijnhondmee.nl/schema/beach.schema.json",
  "title": "Strand met hondenregels",
  "type": "object",
  "additionalProperties": false,
  "required": ["id","name","plaats","gemeente","provincie","location","seasons","exceptions","cleanup_required","status","source_url","sources","checked_at"],
  "properties": {
    "id": {"type":"string","pattern":"^[a-z0-9-]+$","description":"Slug, gelijk aan bestandsnaam"},
    "name": {"type":"string"},
    "plaats": {"type":"string"},
    "gemeente": {"type":"string"},
    "provincie": {"enum":["Groningen","Friesland","Noord-Holland","Zuid-Holland","Zeeland","Flevoland","Gelderland","Utrecht","Overijssel","Drenthe","Noord-Brabant","Limburg"]},
    "location": {"description":"Alleen invullen als uit bron afkomstig, anders null","oneOf":[{"type":"null"},{"type":"object","required":["lat","lng","source"],"properties":{"lat":{"type":"number"},"lng":{"type":"number"},"source":{"type":"string","format":"uri"}}}]},
    "seasons": {"type":"array","minItems":1,"items":{"$ref":"#/$defs/season"}},
    "leash_notes": {"type":["string","null"]},
    "exceptions": {"type":"array","items":{"type":"string"}},
    "cleanup_required": {"type":["boolean","null"],"description":"null = onbekend"},
    "status": {"enum":["verified","partial","unknown"]},
    "source_url": {"type":"string","format":"uri","description":"Primaire (bij voorkeur officiële) bron"},
    "sources": {"type":"array","minItems":1,"items":{"type":"object","required":["url","title","official"],"additionalProperties":false,"properties":{"url":{"type":"string","format":"uri"},"title":{"type":"string"},"official":{"type":"boolean"}}}},
    "checked_at": {"type":"string","format":"date"}
  },
  "$defs": {
    "allowed": {"enum":["yes","no","partly","unknown"]},
    "leash": {"enum":["off_leash","on_leash","mixed","unknown","not_applicable"]},
    "mmdd": {"type":"string","pattern":"^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$"},
    "hhmm": {"type":"string","pattern":"^([01][0-9]|2[0-3]):[0-5][0-9]$"},
    "season": {"type":"object","additionalProperties":false,"required":["label","from","to","dogs_allowed","leash","time_windows"],
      "properties":{"label":{"type":"string"},"from":{"$ref":"#/$defs/mmdd"},"to":{"$ref":"#/$defs/mmdd"},
        "dogs_allowed":{"$ref":"#/$defs/allowed"},"leash":{"$ref":"#/$defs/leash"},"notes":{"type":"string"},
        "time_windows":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to","dogs_allowed","leash"],
          "properties":{"from":{"$ref":"#/$defs/hhmm"},"to":{"$ref":"#/$defs/hhmm"},"dogs_allowed":{"$ref":"#/$defs/allowed"},"leash":{"$ref":"#/$defs/leash"},"notes":{"type":"string"}}}}}}
  }
}
