{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "imports-v2/checklist_items.json",
  "title": "Checklist items",
  "description": "One item of a checklist, such as \"Write the definition\", that can be checked off. Items belong to a checklist from `checklists`. The items of a checklist keep the order of their records. Check data (`checked_at`, `checker_ref`) is allowed only for a checked item.",
  "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."
    },
    "checklist_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "checklists",
      "description": "The checklist the item belongs to. Give the external_id of a `checklists` record."
    },
    "text": {
      "type": "string",
      "minLength": 1,
      "description": "The item's text, for example `Write the definition`."
    },
    "checked": {
      "type": "boolean",
      "description": "Whether the item is done.",
      "default": false
    },
    "checked_at": {
      "type": [
        "string",
        "null"
      ],
      "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 item was checked off. Allowed only when `checked` is true."
    },
    "checker_ref": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "users",
      "description": "The user who checked the item off. Allowed only when `checked` is true. Give the external_id of a `users` record."
    },
    "author_ref": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "users",
      "description": "The user who added the item to the checklist. Give the external_id of a `users` record."
    },
    "responsible_ref": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "users",
      "description": "The user responsible for the item. Give the external_id of a `users` record."
    },
    "due_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "pattern": "^2\\d{3}-\\d{2}-\\d{2}$",
      "description": "The day the item is due, as a plain `YYYY-MM-DD` string, for example `\"2026-03-31\"`. Unlike the card's `due_date`, it is not an object and has no time. The year must be between 2000 and 2999."
    }
  },
  "required": [
    "external_id",
    "checklist_ref",
    "text"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "checked": {
            "enum": [
              true
            ]
          }
        },
        "required": [
          "checked"
        ]
      },
      "else": {
        "properties": {
          "checked_at": {
            "type": "null"
          },
          "checker_ref": {
            "type": "null"
          }
        }
      }
    }
  ]
}
