{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "user.schema.json",
    "title": "User",
    "type": "object",
    "description": "Пользователь",
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "description": "Уникальный идентификатор"
        },
        "type": {
            "enum": ["CUSTOMER", "EMPLOYEE", "AGENT", "PARTNER"],
            "description": "Тип пользователя \n\n - `CUSTOMER`: клиент \n - `EMPLOYEE`: исполнитель \n - `AGENT`: агент, \n - `PARTNER`: партнёр"
        },
        "customer": {
            "$ref" : "customer.schema.json",
            "description": "Клиент"
        },
        "employee": {
            "$ref" : "employee.schema.json",
            "description": "Сотрудник"
        },
        "agent": {
            "$ref" : "agent.schema.json",
            "description": "Agent"
        },
        "partner": {
            "$ref" : "partner.schema.json",
            "description": "Partner"
        },
        "email": {
            "$ref": "common/_common.schema.json#/email",
            "description": "E-mail пользователя"
        },
        "phone": {
            "type" : "string",
            "pattern": "^(79)\\d{9}$",
            "description": "Номер мобильного телефона"
        },
        "role" :  {
            "$ref": "common/_common.schema.json#/userRole"
        },
        "status"  : {
            "$ref": "common/_common.schema.json#/status",
            "description": "Статус пользователя"
        },
        "statusPrevious"  : {
            "$ref": "common/_common.schema.json#/status",
            "description": "Предыдущий статус пользователя"
        },
        "statusReason"  : {
            "enum": ["PASSWORD_MISTAKE", "MANUAL_BLOCKED"],
            "description": "Причина установки текущего статуса  \n\n - `PASSWORD_MISTAKE`: ошибка ввода пароля \n - `MANUAL_BLOCKED`: ручная блокировка"
        },
        "passwordMistakeCounter"  : {
            "type": "number",
            "description": "Количество попыток ошибочного ввода пароля при входе в систему"
        },
        "lastName": {
            "type": "string",
            "description": "Фамилия"
        },
        "firstName": {
            "type": "string",
            "description": "Имя"
        },
        "patronymic": {
            "type": "string",
            "description": "Отчество"
        }

    },
    "required": [
        "id",
        "type",
        "email",
        "phone",
        "role",
        "status"
    ]
}