{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "person.schema.json",
    "title": "Person",
    "type": "object",
    "description": "Физическое лицо",
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "description": "Уникальный идентификатор"
        },
        "customer": {
            "Sref": "customer.schema.json"
        },
        "fio": {
            "$ref": "common/_common.schema.json#/fio"
        },
        "fioDativeCase": {
            "$ref": "common/_common.schema.json#/fio",
            "description": "ФИО в дательном падеже"
        },
        "fioEnglish": {
            "$ref": "common/_common.schema.json#/fio",
            "description": "ФИО на английском языке"
        },
        "inn": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9]{12}$",
            "description": "ИНН"
        },
        "addressRegistration": {
            "description": "Адрес регистрации",
            "$ref": "common/_common.schema.json#/address"
        },
        "addressRegistrationEnglish": {
            "description": "Адрес регистрации на английском языке",
            "$ref": "common/_common.schema.json#/address"
        },
        "citizenship": {
            "$ref": "common/_common.schema.json#/country",
            "description": "Страна гражданства"
        },
        "taxResidence": {
            "$ref": "common/_common.schema.json#/country",
            "description": "Страна налогового резидентства"
        },
        "passport": {
            "description": "Паспорт",
            "properties": {
                "series": {
                    "type": "string",
                    "description": "Серия"
                },
                "number": {
                    "type": "string",
                    "description": "Номер"
                },
                "issueDate": {
                    "type": "string",
                    "format": "date",
                    "description": "Дата выдачи"
                },
                "issuedBy": {
                    "type": "string",
                    "description": "Кем выдан"
                },
                "issueOrganizationCode": {
                    "type": "string",
                    "description": "Код подразделения выдавшего паспорт"
                }
            },
            "additionalProperties": false,
            "required": [
                "number",
                "issueDate",
                "issuedBy"
            ]
        },
        "bankAccount": {
            "$ref": "common/_common.schema.json#/bankAccount"
        },
        "ogrnip": {
            "type": "string",
            "minLength": 15,
            "maxLength": 15,
            "pattern": "^[0-9]{15}$",
            "description": "ОГРН индивидуального предпринимателя. Заполняется, если Тип заказчика = ИП"
        }
    },
    "additionalProperties": false,
    "required": [
        "id",
        "fio",
        "inn",
        "taxResidence"
    ],
    "if": {
        "properties": {
            "citizenship": {
                "const": "RUS"
            }
        },
        "required": [
            "citizenship"
        ]
    },
    "then": {
        "properties": {
            "passport": {
                "required": [
                    "issueOrganizationCode"
                ]
            }
        }
    }
}