user_management.domain.validation.user package

Submodules

user_management.domain.validation.user.user_validator module

class user_management.domain.validation.user.user_validator.UserValidator[source]

Bases: object

Centralized validator for User entity creation and updates.

Applies domain rules through reusable Specification objects to ensure data integrity. This class encapsulates all validation logic, enabling clean separation from the User entity and promoting testability, reuse, and maintainability.

Validation includes: - UUID format - Email validity - Name character constraints - Phone number in E.164 format - Realistic and non-future date of birth - Valid role and status enums

static validate(uuid: UUID, email: str, first_name: str, last_name: str, phone, date_of_birth, role: UserRole, status: UserStatus, created_at: datetime, updated_at: datetime) None[source]

Validates user data against domain rules before entity creation.

Executes a series of checks using Specifications. Raises specific domain exceptions if any validation fails. All validations are executed sequentially.

Parameters:
  • uuid (UUID) – Unique identifier; must be a valid UUID instance.

  • email (str) – Email address; must be properly formatted.

  • first_name (str) – First name; must contain only letters and spaces.

  • last_name (str) – Last name; must contain only letters and spaces.

  • phone (str, optional) – Phone number in E.164 format (e.g., +1234567890). May be None.

  • date_of_birth (date) – Date of birth; must not be in the future or unrealistic.

  • role (UserRole) – Assigned role; must be a valid UserRole enum member.

  • status (UserStatus) – Account status; must be a valid UserStatus enum member.

Raises:

Module contents

Public API for User validation services.

This module provides the UserValidator class for enforcing domain rules during user creation and updates. It encapsulates all validation logic, including email format, name validity, phone number (E.164), date of birth, and role/status integrity.

Import directly from this package: from src.user_management.domain.validation.user import UserValidator

class user_management.domain.validation.user.UserValidator[source]

Bases: object

Centralized validator for User entity creation and updates.

Applies domain rules through reusable Specification objects to ensure data integrity. This class encapsulates all validation logic, enabling clean separation from the User entity and promoting testability, reuse, and maintainability.

Validation includes: - UUID format - Email validity - Name character constraints - Phone number in E.164 format - Realistic and non-future date of birth - Valid role and status enums

static validate(uuid: UUID, email: str, first_name: str, last_name: str, phone, date_of_birth, role: UserRole, status: UserStatus, created_at: datetime, updated_at: datetime) None[source]

Validates user data against domain rules before entity creation.

Executes a series of checks using Specifications. Raises specific domain exceptions if any validation fails. All validations are executed sequentially.

Parameters:
  • uuid (UUID) – Unique identifier; must be a valid UUID instance.

  • email (str) – Email address; must be properly formatted.

  • first_name (str) – First name; must contain only letters and spaces.

  • last_name (str) – Last name; must contain only letters and spaces.

  • phone (str, optional) – Phone number in E.164 format (e.g., +1234567890). May be None.

  • date_of_birth (date) – Date of birth; must not be in the future or unrealistic.

  • role (UserRole) – Assigned role; must be a valid UserRole enum member.

  • status (UserStatus) – Account status; must be a valid UserStatus enum member.

Raises: