Skip to content

Introduce Email and CPF Value Objects#89

Open
ericklucioh wants to merge 23 commits intobrunoclz:mainfrom
ericklucioh:erick
Open

Introduce Email and CPF Value Objects#89
ericklucioh wants to merge 23 commits intobrunoclz:mainfrom
ericklucioh:erick

Conversation

@ericklucioh
Copy link
Copy Markdown
Contributor

Summary

Refactor of CPF/CNPJ document handling to improve consistency, validation safety, and object-oriented design.

  • Removed incorrect use of @dataclass in inherited classes
  • Centralized normalization logic in base Document class
  • Enforced validation at object construction (invalid documents can no longer be instantiated)
  • Simplified get_identifier by relying on constructor validation instead of duplicated checks

This change ensures stronger domain integrity and aligns the implementation with Value Object patterns.

Release metadata

Release note (PT-BR):
Refatoração da validação e modelagem de CPF/CNPJ para garantir integridade dos objetos e melhorar a estrutura orientada a objetos.

Release note (EN):
Refactor of CPF/CNPJ validation and modeling to ensure object integrity and improve object-oriented structure.

Release highlights (PT-BR, bullets with |):
Validação garantida na criação de CPF/CNPJ | Remoção de uso incorreto de dataclass | Código mais consistente e seguro

Release highlights (EN, bullets with |):
Validation enforced at object creation | Removed incorrect dataclass usage | More consistent and safer code

Included pattern IDs (comma-separated, or none):
none

Technical changes (PT-BR, bullets with |):
Remoção de @DataClass em classes herdadas | Uso correto de herança com super().init | Validação movida para construtor | Simplificação da função get_identifier

Technical changes (EN, bullets with |):
Removed @DataClass from inherited classes | Proper inheritance using super().init | Validation moved to constructor | Simplified get_identifier function

Change type (choose one release label from taxonomy):

  • release:major
  • release:feature
  • release:patterns
  • release:api
  • release:data
  • release:privacy
  • release:fix
  • release:docs
  • release:infra
  • release:security

Breaking change?

  • No
  • Yes (describe migration/impact in summary)

Validation

  • Local tests/checks passed for impacted scope
  • CI and Security checks are green
  • Exactly one release label is set on this PR

Public safety and compliance checklist

  • No personal identifier exposure was introduced
  • PUBLIC_MODE behavior was reviewed (if relevant)
  • Public boundary gate is green
  • Public endpoints and demo data contain no personal data fields
  • Legal/policy docs were reviewed for scope-impacting changes
  • Snapshot boundary remains compliant with docs/release/public_boundary_matrix.csv

Risk and rollback

Risks:

  • Existing code that instantiates Cpf/Cnpj without validation may now raise exceptions
  • Hidden dependencies relying on previous permissive behavior

Rollback plan:

  • Revert this PR to restore previous behavior
  • Alternatively, temporarily reintroduce is_valid checks before instantiation in callers

@github-actions github-actions bot added the release:feature New user-facing capability label Apr 3, 2026
@ericklucioh ericklucioh marked this pull request as ready for review April 3, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:feature New user-facing capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant