# UpdatePartnerIdentification

## Overview

updatePartnerIdentification modifies the fields of an existing partner identification. Identification type is fixed by the existing record and is not part of the update input. When the value is updated, uniqueness is re-validated against the company scope to prevent duplicate registrations.

## Business Rules

- Identification must exist in the system
- Type is not part of the update input
- If value is provided, it must be non-empty and not whitespace-only
- If value is changed, the new (type, value) combination must be unique within the company scope
- When both validFrom and validTo are set, validTo must be greater than or equal to validFrom
- Issuing country and validity dates are optional

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B{Identification exists?}
    B -->|No| C[Return error: identification not found]
    B -->|Yes| D{Value provided?}
    D -->|Yes| D2{Value non-empty after trim?}
    D2 -->|No| D3[Return error: invalid value]
    D2 -->|Yes| E{Value changed and new type + value unique in company?}
    E -->|No| F[Return error: duplicate identification]
    E -->|Yes| G{Validate validity period}
    D -->|No| G
    G -->|validTo < validFrom| H[Return error: invalid validity period]
    G -->|Valid| I[Update identification record]
    I --> J[Return updated identification]
```

## External Dependencies

- None

## Error Scenarios

- **IDENTIFICATION_NOT_FOUND**: Specified identification ID does not exist
- **INVALID_VALUE**: Provided value is empty or whitespace-only
- **DUPLICATE_IDENTIFICATION**: Updated (type, value) combination already exists within the company
- **INVALID_VALIDITY_PERIOD**: validTo is earlier than validFrom

## Test Cases

- updates identification value
- returns error when identification not found
- returns error when value is empty
- returns error when value is whitespace-only
- returns error when updated value creates duplicate
- returns error when validity period is invalid
