{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "imports-v2/card_blockers.json",
  "title": "Card blockers",
  "description": "A block on a card: the card cannot move on because of another card or because of a stated reason. Use it for a card waiting on a card (`blocker_card_ref`), or for a block that only has a `reason`; a block with neither is invalid. Give only blocks that are active now; the import creates every block as active.",
  "type": "object",
  "properties": {
    "external_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Your own identifier of the record, for example `k-mrr`, unique within the resource across all of its files and case sensitive. Other records refer to this one by it."
    },
    "card_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "cards",
      "description": "The card that is blocked. Give the external_id of a `cards` record."
    },
    "blocker_card_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "cards",
      "description": "The card that causes the block. Leave it out for a block that only has a `reason`.",
      "x-required-when": "reason is absent or null"
    },
    "reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why the card is blocked, for example `The cohorts must be defined first.` Required when there is no `blocker_card_ref`.",
      "x-required-when": "blocker_card_ref is absent"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$",
      "description": "When the block was set, for example `2026-03-09T10:05:00Z`."
    },
    "due_date": {
      "anyOf": [
        {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "precision": {
                  "type": "string",
                  "enum": [
                    "date"
                  ],
                  "description": "Always date."
                },
                "value": {
                  "type": "string",
                  "format": "date",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                }
              },
              "required": [
                "precision",
                "value"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "precision": {
                  "type": "string",
                  "enum": [
                    "date_time"
                  ],
                  "description": "Always date_time."
                },
                "value": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"
                }
              },
              "required": [
                "precision",
                "value"
              ],
              "additionalProperties": false
            }
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The date by which the block should be gone. A date without time stays a date."
    }
  },
  "required": [
    "external_id",
    "card_ref",
    "created_at"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "required": [
          "blocker_card_ref"
        ]
      },
      "else": {
        "required": [
          "reason"
        ],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  ]
}
