Table of Contents | ||
---|---|---|
|
...
Validate request using JSON schema
In case validation fails - generate 422 error
Validate $.party.documents.[].number according to regexp and document type:
PASSPORT -
^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$
NATIONAL_ID -
^[0-9]{9}$
COMPLEMENTARY_PROTECTION_CERTIFICATE -
^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$
REFUGEE_CERTIFICATE -
^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$
TEMPORARY_CERTIFICATE -
^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\\/[0-9]{5})$
TEMPORARY_PASSPORT -
^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$
in case of error - return 422 ('string does not match pattern') with the corresponding regexp
Validate request (Logic)
Check employee_type: Employee configurable validation rules and dictionaries
If employee_id is passed in the payload:
search employees by employee_id
if not found - return error 404
check that employee_type not in (OWNER, PHARMACY_OWNER)
in case of error - return 409 “Forbidden to create <employee_type>“
check employee_type and tax_id (or passport_id, if no_tax_id: true)
If dosn't match, return error 409 “<field> doesn't match"
check that employee is active (status = APPROVED and is_active = true)
in case of error - return 409 “employee is <status>“
Check allowed employee types for legal_entity type: Legal_Entity_Type vs Employee_Type validation rules
if not found - return error 404
Validate legal entity type status for current legal entity: status should be active or suspended
Check that documents.[x].type contain values from
IDENTITY_DOCUMENT_TYPESEMPLOYEE_IDENTITY_DOCUMENT_TYPES chart parameterin case of error - return 422 (“Submitted document type is not allowed“)
Check that document types NATIONAL_ID and PASSPORT both do not exist in request
in case of error - return 422 ('Employee can have only one of following document types [\"PASSPORT\", \"NATIONAL_ID\"]')
Alternative notation 2 of validation :
...