{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://preparedboard.com/standard/v1/drafts/vote-tally.schema.json",
  "title": "prepared-board.vote-tally.v1",
  "description": "DRAFT. One certified vote with the quorum that was present. Nothing is sealed in this format yet. Docs: https://preparedboard.com/standard#drafts",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "voteSessionId",
    "decisionId",
    "boardId",
    "meetingId",
    "version",
    "method",
    "threshold",
    "quorum",
    "roster",
    "positions",
    "tally",
    "result",
    "certifiedAt"
  ],
  "properties": {
    "schema": {
      "const": "prepared-board.vote-tally.v1"
    },
    "voteSessionId": {
      "type": "string",
      "minLength": 1
    },
    "decisionId": {
      "type": "string",
      "minLength": 1
    },
    "boardId": {
      "type": "string",
      "minLength": 1
    },
    "meetingId": {
      "type": [
        "string",
        "null"
      ]
    },
    "version": {
      "type": "integer",
      "minimum": 1
    },
    "method": {
      "type": "string",
      "minLength": 1
    },
    "threshold": {
      "type": "string",
      "minLength": 1
    },
    "quorum": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "base",
        "formula",
        "seats",
        "required",
        "present",
        "met",
        "recusedCountTowardQuorum"
      ],
      "properties": {
        "base": {
          "enum": [
            "AUTHORIZED_SEATS",
            "IN_OFFICE"
          ]
        },
        "formula": {
          "type": "string",
          "minLength": 1
        },
        "seats": {
          "type": "integer",
          "minimum": 1
        },
        "required": {
          "type": "integer",
          "minimum": 1
        },
        "present": {
          "type": "integer",
          "minimum": 0
        },
        "met": {
          "type": "boolean"
        },
        "recusedCountTowardQuorum": {
          "type": "boolean"
        }
      }
    },
    "roster": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "positions": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "memberId",
              "choice"
            ],
            "properties": {
              "memberId": {
                "type": "string",
                "minLength": 1
              },
              "choice": {
                "enum": [
                  "FOR",
                  "AGAINST",
                  "ABSTAIN",
                  "RECUSED",
                  "ABSENT"
                ]
              }
            }
          }
        }
      ]
    },
    "tally": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "for",
        "against",
        "abstain",
        "recused",
        "absent"
      ],
      "properties": {
        "for": {
          "type": "integer",
          "minimum": 0
        },
        "against": {
          "type": "integer",
          "minimum": 0
        },
        "abstain": {
          "type": "integer",
          "minimum": 0
        },
        "recused": {
          "type": "integer",
          "minimum": 0
        },
        "absent": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "result": {
      "enum": [
        "ADOPTED",
        "DEFEATED",
        "TIED"
      ]
    },
    "certifiedAt": {
      "type": "string",
      "format": "date-time"
    }
  }
}
