Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
stylenone

...

  1. Validate request using JSON schema

    1. In case validation fails - generate 422 error

  2. Validate $.party.documents.[].number according to regexp and document type:

    1. PASSPORT - ^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$

    2. NATIONAL_ID - ^[0-9]{9}$

    3. COMPLEMENTARY_PROTECTION_CERTIFICATE - ^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$

    4. REFUGEE_CERTIFICATE - ^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$

    5. TEMPORARY_CERTIFICATE - ^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\\/[0-9]{5})$

    6. TEMPORARY_PASSPORT - ^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$

      1. in case of error - return 422 ('string does not match pattern') with the corresponding regexp

Validate request (Logic)

  1. Check employee_type: Employee configurable validation rules and dictionaries

  2. If employee_id is passed in the payload:

    1. search employees by employee_id

      1. if not found - return error 404

    2. check that employee_type not in (OWNER, PHARMACY_OWNER)

      1. in case of error - return 409 “Forbidden to create <employee_type>“

    3. check employee_type and tax_id (or passport_id, if no_tax_id: true)

      1. If dosn't match, return error 409 “<field> doesn't match"

    4. check that employee is active (status = APPROVED and is_active = true)

      1. in case of error - return 409 “employee is <status>“

  3. Check allowed employee types for legal_entity type: Legal_Entity_Type vs Employee_Type validation rules

    1. if not found - return error 404

  4. Validate legal entity type status for current legal entity: status should be active or suspended

  5. Check that documents.[x].type contain values from IDENTITY_DOCUMENT_TYPESEMPLOYEE_IDENTITY_DOCUMENT_TYPES chart parameter

    • in case of error - return 422 (“Submitted document type is not allowed“)

  6. 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 :

...