{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://redbook.fun/specification/1.0/schemas/domain-recurrence.schema.json",
  "title": "Finite recurrence descriptors and explicit exceptions",
  "oneOf": [
    {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    {
      "$ref": "#/$defs/interval"
    },
    {
      "$ref": "#/$defs/rrule"
    }
  ],
  "$defs": {
    "interval": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "interval"
        },
        "everyMilliseconds": {
          "type": "string",
          "pattern": "^[1-9][0-9]*(?![\\s\\S])"
        },
        "count": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "until": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "kind",
        "everyMilliseconds"
      ],
      "additionalProperties": false,
      "not": {
        "required": [
          "count",
          "until"
        ]
      }
    },
    "rrule": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "rrule"
        },
        "rule": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "kind",
        "rule"
      ],
      "additionalProperties": false
    },
    "exception": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "occurrence": {
              "type": "string",
              "minLength": 1
            },
            "cancelled": {
              "const": true
            }
          },
          "required": [
            "occurrence",
            "cancelled"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "occurrence": {
              "type": "string",
              "minLength": 1
            },
            "start": {
              "type": "string",
              "minLength": 1
            },
            "end": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "occurrence",
            "start",
            "end"
          ],
          "additionalProperties": false
        }
      ]
    }
  }
}
