{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://namkg-blip.github.io/face-value/face-value-terms-0.1.schema.json",
  "title": "face-value-terms 0.1",
  "description": "An event organizer's face values, fees, per-buyer limits and resale rules. Amounts have at most 2 decimals. Known gaps in 0.1: concession or per-purchase prices, resale platform fee caps, a currency per event, signatures. Amounts and cap_percent have at most 2 decimals; that is checked by tools/check_terms.mjs, not by this schema, because JSON Schema multipleOf fails on binary floating point.",
  "type": "object",
  "required": [
    "format",
    "publisher",
    "currency",
    "events"
  ],
  "properties": {
    "format": {
      "const": "face-value-terms/0.1"
    },
    "publisher": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "note": {
          "type": "string"
        }
      }
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "updated": {
      "type": "string",
      "format": "date"
    },
    "events": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "title",
          "date",
          "per_buyer_limit",
          "resale",
          "tiers"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "time": {
            "type": "string"
          },
          "per_buyer_limit": {
            "type": "integer",
            "minimum": 1
          },
          "resale": {
            "type": "object",
            "required": [
              "allowed"
            ],
            "properties": {
              "allowed": {
                "type": "boolean"
              },
              "cap_percent": {
                "type": "number",
                "minimum": 0,
                "maximum": 1000
              },
              "cap_includes_fees": {
                "type": "boolean"
              },
              "note": {
                "type": "string"
              }
            },
            "if": {
              "properties": {
                "allowed": {
                  "const": true
                }
              }
            },
            "then": {
              "required": [
                "cap_percent",
                "cap_includes_fees"
              ]
            }
          },
          "tiers": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "id",
                "name",
                "face_value"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "aliases": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "face_value": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "fees": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "number",
                    "minimum": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}