user_management.domain.specifications.user package
Submodules
user_management.domain.specifications.user.date_of_birth module
user_management.domain.specifications.user.email module
user_management.domain.specifications.user.name module
user_management.domain.specifications.user.phone module
Module contents
Public API for User-related business rule specifications.
This module provides composable, reusable specification objects that encapsulate domain validation rules for the User entity. These specifications are used to enforce business invariants during user creation, profile updates, and system audits.
Each specification implements the is_satisfied_by(value) -> bool interface, enabling clean, testable, and readable validation logic within the domain layer.
Specifications support: - Fail-fast validation - Reusability across use cases - Composability (e.g., AND/OR rules) - Clear separation of concerns
They are central to enforcing data integrity, security, and compliance (e.g., HIPAA/GDPR).
Import specifications directly using:
from src.user_management.domain.specifications.user import (
ValidEmailSpecification,
ValidNameSpecification,
ValidPhoneE164Specification,
ValidDateOfBirthSpecification,
ValidUserRoleSpecification,
ValidUserStatusSpecification,
ValidCreatedAtSpecification,
ValidUpdatedAtSpecification
)
- class user_management.domain.specifications.user.ValidCreatedAtSpecification[source]
Bases:
SpecificationSpecification to validate that created_at is a valid timestamp for user creation.
Enforces temporal integrity by rejecting invalid or impossible timestamps. Used during User aggregate construction to ensure domain invariants are preserved.
- class user_management.domain.specifications.user.ValidDateOfBirthSpecification[source]
Bases:
SpecificationSpecification to validate that a date of birth is realistic and properly formatted.
Enforces domain invariants for user age during creation and updates. Used within the User aggregate to prevent invalid or impossible dates.
- class user_management.domain.specifications.user.ValidEmailSpecification[source]
Bases:
SpecificationSpecification to validate that an email address conforms to structural rules.
Ensures only properly formatted emails are accepted in the domain layer. Used within the User aggregate to enforce fail-fast validation and prevent invalid identities.
- class user_management.domain.specifications.user.ValidNameSpecification[source]
Bases:
SpecificationSpecification to validate that a first or last name conforms to allowed format rules.
Enforces clean, readable names within the User aggregate. Used during creation and updates to maintain data integrity in healthcare workflows.
- class user_management.domain.specifications.user.ValidPhoneE164Specification[source]
Bases:
SpecificationSpecification to validate that a phone number conforms to the E.164 international standard.
Enforces consistent formatting across user profiles and supports integration with third-party telephony providers. Used within the User aggregate for fail-fast validation.
- class user_management.domain.specifications.user.ValidUUIDSpecification[source]
Bases:
SpecificationSpecification to validate that a UUID is a properly typed identity object.
Enforces strict type checking to ensure only valid UUID instances are accepted during User aggregate creation. Prevents common errors like passing strings or None as identifiers in critical healthcare workflows.
- class user_management.domain.specifications.user.ValidUpdatedAtSpecification[source]
Bases:
SpecificationSpecification to validate that updated_at is a valid timestamp for user record updates.
Enforces temporal correctness by rejecting invalid or impossible timestamps. Used during User aggregate construction to ensure domain invariants are preserved.
- class user_management.domain.specifications.user.ValidUserRoleSpecification[source]
Bases:
SpecificationSpecification to validate that a user role is a valid enum member.
Enforces domain integrity by rejecting strings, None, or invalid types during User creation or role updates. Ensures only approved roles are assigned.
- class user_management.domain.specifications.user.ValidUserStatusSpecification[source]
Bases:
SpecificationSpecification to validate that a user status is a valid enum member.
Enforces domain integrity by rejecting strings, None, or invalid types during User creation or status updates. Ensures only approved states are assigned.