{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openteesheet.com/schemas/league-team.schema.json",
  "title": "OpenTeeSheet league team (open format v1)",
  "description": "A team in a league season and its roster: the golfers who paid (or pay at the venue). A golfer who deletes their account leaves every roster; the team's posted scores stay.",
  "type": "object",
  "properties": {
    "object": {
      "const": "league_team"
    },
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "season_id": {
      "type": "string",
      "format": "uuid"
    },
    "venue_id": {
      "type": "string",
      "format": "uuid"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 40
    },
    "roster": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "captain",
              "player"
            ]
          },
          "payment_status": {
            "type": "string",
            "enum": [
              "paid",
              "at_venue",
              "free"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "role",
          "payment_status"
        ],
        "additionalProperties": false
      }
    },
    "created_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "required": [
    "object",
    "id",
    "season_id",
    "venue_id",
    "name",
    "roster"
  ],
  "additionalProperties": false
}
