{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chatmock.studio/dialogue.schema.json",
  "title": "ChatMock dialogue",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "theme",
    "os",
    "name",
    "messages"
  ],
  "properties": {
    "theme": {
      "enum": [
        "whatsapp",
        "telegram",
        "imessage"
      ]
    },
    "os": {
      "enum": [
        "ios",
        "android"
      ]
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50
    },
    "status": {
      "type": "string",
      "maxLength": 70
    },
    "date": {
      "type": "string",
      "maxLength": 40
    },
    "time": {
      "type": "string",
      "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$"
    },
    "messages": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "side",
          "time",
          "delivery"
        ],
        "properties": {
          "type": {
            "enum": [
              "text",
              "voice"
            ]
          },
          "side": {
            "enum": [
              "in",
              "out"
            ]
          },
          "time": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$"
          },
          "delivery": {
            "enum": [
              "sent",
              "delivered",
              "read"
            ]
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "duration": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3600
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "type": {
                  "const": "text"
                }
              }
            },
            "then": {
              "required": [
                "text"
              ]
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "const": "voice"
                }
              }
            },
            "then": {
              "required": [
                "duration"
              ]
            }
          }
        ]
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "theme": {
            "const": "imessage"
          }
        }
      },
      "then": {
        "properties": {
          "os": {
            "const": "ios"
          }
        }
      }
    }
  ]
}