{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "players": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "createdAt",
          "name",
          "description"
        ]
      }
    },
    "games": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "ruleset": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "color": {
            "type": "string"
          },
          "icon": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "createdAt",
          "name",
          "ruleset",
          "description",
          "color",
          "icon"
        ]
      }
    },
    "groups": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "memberIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "createdAt",
          "description",
          "memberIds"
        ]
      }
    },
    "matches": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "endedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "gameId": {
            "type": "string"
          },
          "groupId": {
            "type": [
              "string",
              "null"
            ]
          },
          "playerIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scores": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "null"
                },
                {
                  "type": "object",
                  "properties": {
                    "roundNumber": {
                      "type": "number"
                    },
                    "score": {
                      "type": "number"
                    },
                    "change": {
                      "type": "number"
                    }
                  },
                  "required": ["roundNumber", "score", "change"],
                  "additionalProperties": false
                }
              ]
            }
          },
          "notes": {
            "type": "string"
          },
          "isTeamMatch": {
            "type": "boolean"
          },
          "teams": {
            "type": ["array", "null"]
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "createdAt",
          "gameId",
          "playerIds",
          "notes",
          "isTeamMatch"
        ]
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "players",
    "games",
    "groups",
    "matches"
  ]
}