Skip to content

Releases: potatowski/brazilcode

v3.1.0

Choose a tag to compare

@potatowski potatowski released this 24 Jun 00:49
363cda9

[3.1.0] - 2026-06-20

Added

  • Alphanumeric CNPJ support (in effect from July 2026): the 12-character base may
    now contain the letters A-Z in addition to digits, followed by 2 numeric
    check digits. Each character contributes its value as ASCII − '0' (digits map
    to 0-9, letters to 17-42) using the same mod-11 algorithm as numeric CNPJ.
  • CNPJ.GenerateAlphanumeric() generates a random valid alphanumeric CNPJ.
  • digit.RemoveCNPJFormatting strips CNPJ formatting (dots, dashes, slashes,
    whitespace) and upper-cases the result while preserving letters.
  • digit.GenerateAlphanumericChars generates random alphanumeric characters
    (0-9, A-Z).

Changed

  • CNPJ.IsValid and CNPJ.Format now accept both numeric (legacy) and
    alphanumeric CNPJs. Input is sanitized with RemoveCNPJFormatting (which keeps
    letters) instead of RemoveNonDigits. As a result, a 14-character input that
    contains letters and matches the alphanumeric shape but fails the checksum now
    returns ErrCNPJInvalid rather than ErrCNPJInvalidLength.

v3.0.0

Choose a tag to compare

@potatowski potatowski released this 13 Apr 05:38
v3.0.0

Added

  • Functional options pattern for Generate method (WithUF for VoterRegistration).
  • Validation for identical-digit documents (e.g., 111.111.111-11 for CPF, 11.111.111/1111-11 for CNPJ).
  • internal/digit package with pre-compiled regex and strings.Builder optimizations.
  • Benchmarks for all document types (validation, formatting, generation).
  • Document interface with Option type alias for cross-package compatibility.
  • Exported document variables (brazilcode.CPF, brazilcode.CNPJ, etc.) for direct use.
  • ErrDocTypeNotSupported exported error for better error handling.
  • Sub-package usage: each document type can be imported individually.
  • Migration guide in README.

Changed

  • BREAKING: Module path changed from v2 to v3.
  • BREAKING: Generate signature changed from Generate(params map[string]string) to Generate(opts ...Option).
  • BREAKING: Removed src/ directory — packages moved to root-level sub-packages (cpf/, cnpj/, cnh/, renavam/, voter/).
  • BREAKING: Removed iface package — Document interface now lives in root brazilcode package.
  • BREAKING: voterRegistration package renamed to voter.
  • Replaced regexp.MustCompile per-call with pre-compiled package-level regex.
  • Replaced string concatenation (+=) with strings.Builder for document generation.
  • Replaced fmt.Sprintf("%d", ...) with strconv.Itoa(...) for digit conversion.
  • Replaced rand.Seed (deprecated) — uses global math/rand source.
  • Consolidated utility functions into internal/digit (unexported to consumers).
  • CNH Generate now retries on rare edge cases where check digits exceed single digit.

Removed

  • src/ directory (Go anti-pattern).
  • iface package (unnecessary indirection).
  • utils package (consolidated into internal/digit).
  • Debug fmt.Println in voter registration generation.

v2.1.0

Choose a tag to compare

@potatowski potatowski released this 31 Mar 21:53
8afd1b1

What's Changed

Added

  • Implement RENAVAM validation and generation functions.
  • Add RENAVAM instance for vehicle registration management.
  • Add unit tests for RENAVAM validation, formatting, and generation.
  • Add unit tests for Document interface using a mock implementation.
  • Add documentation for CPF, CNPJ, CNH, and VoterRegistration.

Changed

  • Update README to reflect module path change to v2.
  • Update README to include RENAVAM in the list of features.
  • Update CHANGELOG with new RENAVAM features and unit tests.

Full Changelog: v2.0.0...v2.1.0

v2.0.0

Choose a tag to compare

@potatowski potatowski released this 26 Mar 19:04
8f757f5

What's Changed

Added

  • Document interface for document operations.
  • IsValid, Format, and Generate methods for document validation and formatting.

Changed

  • Converted voter registration functions to methods of VoterRegistration struct implementing the Document interface.
  • Converted CPF functions to methods of CPF struct implementing the Document interface.
  • Converted CNPJ functions to methods of CNPJ struct implementing the Document interface.
  • Converted CNH functions to methods of CNH struct implementing the Document interface.
  • Consolidated document operations into a unified interface with IsValid, Format, and Generate methods.
  • Updated README to reflect method changes for CNPJ and VoterRegistration.
  • Enhanced clarity on package functionality and usage examples in README.

Fixed

  • Updated voter registration test to ignore voter output.

Full Changelog: v1.1.1...v2.0.0

v1.1.1

Choose a tag to compare

@potatowski potatowski released this 20 Apr 19:16
v1.1.1
ffe38ca
improv: added functions about voter registration

v1.1.0

Choose a tag to compare

@potatowski potatowski released this 20 Apr 19:10
1.1.0
607005f
Feat: Voter Registration

v1.0.0

Choose a tag to compare

@potatowski potatowski released this 19 Apr 00:01
1.0.0
c8a8f40

Created feature to validate and generate the document CNH

v. 0.4.2

Choose a tag to compare

@potatowski potatowski released this 14 Apr 20:03
0.4.2
a2f9b3d
Created test