{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "previous_insurance.schema.json",
  "title": "previous_insurance",
  "description": "Enthält Vorversicherungsdaten",
  "type": "object",
  "properties": {
    "has_previous_insurance": {
      "type": "boolean",
      "description": "Ob Vorversicherung besteht/bestand"
    }
  },

  "required": ["has_previous_insurance"],

  "allOf": [
    {
      "if": {"properties": {"has_previous_insurance": {"const": true}}},
      "then": {
        "properties": {
          "product_dependent": {
            "type": "object",
            "properties": {
              "cancelled_by": {
                "$ref": "enums/cancelled_by.schema.json#",
                "description": "Durch wen die Vorversicherung gekündigt wurde: 'insurer', 'me_us'"
              }
            },
            "required": ["cancelled_by"]
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "description": "Name der Vorversicherung"
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "Ende der Vorversicherung 'YYYY-MM-DD'"
          }
        },
        "required": ["name", "end_date"]
      }
    }
  ]
}