Skip to main content

Brazilian document validator (CNPJ numeric and alphanumeric)

Project description

docs-validator

CI Python License

A lightweight Python library for validating Brazilian document identifiers.

Currently the project supports:

  • CNPJ (numeric)
  • Experimental support for alphanumeric CNPJ

The project is designed with:

  • clean architecture
  • automated testing
  • CI/CD
  • PyPI-ready packaging

⚠️ About Alphanumeric CNPJ

As of 2026, there are no alphanumeric CNPJ numbers in public circulation.

The future format has been announced by the Receita Federal do Brasil, but the official database still contains only numeric CNPJ identifiers.

Therefore:

⚠️ Any alphanumeric CNPJ used in this project is only for algorithm testing purposes and does not represent a real company.


Experimental Validation Mode

To allow experimentation with the future format, the library supports an experimental validation mode.

Example:

from docs_validator import validate

validate("12ABC34501DE35", mode="experimental")

When using mode="experimental":

  • letters A-Z are allowed in the first 12 positions
  • letters are converted using base36 mapping
  • the same modulo‑11 check digit algorithm is applied

Mapping example:

A = 10
B = 11
...
Z = 35

Without experimental mode:

validate("12ABC34501DE35")
# returns False

Installation

pip install docs-validator

Usage

Validate numeric CNPJ

from docs_validator import validate

validate("11222333000181")

Validate experimental alphanumeric CNPJ

validate("12ABC34501DE35", mode="experimental")

Format CNPJ

from docs_validator import format_cnpj

format_cnpj("11222333000181")

Output:

11.222.333/0001-81

Running tests

pytest --cov=docs_validator

Generate HTML coverage report:

pytest --cov=docs_validator --cov-report=html

Project structure

docs-validator
│
├── src/
│   └── docs_validator/
│
├── tests/
│
├── pyproject.toml
└── README.md

Roadmap

Planned features:

  • CPF validation
  • document generators
  • CLI interface
  • support for additional Brazilian identifiers
  • benchmarking tools

Author

Bruno Ramos

LinkedIn
https://www.linkedin.com/in/ramosbruno90/

GitHub
https://github.com/thinkbruno


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docs_validator-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docs_validator-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file docs_validator-0.1.0.tar.gz.

File metadata

  • Download URL: docs_validator-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for docs_validator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 310eac5943d6b3d7b24160df76a9d9047bd76e0c4c35c11c5bece0834e990043
MD5 047d2bba0e06dcc70e0b88dc471c21c0
BLAKE2b-256 93ce83007e8a45cd19f30f718065fe795fcdfa931197cf1c523b36e2c7e118e6

See more details on using hashes here.

File details

Details for the file docs_validator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: docs_validator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for docs_validator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44731bf378adb7eaab23f55e00214d67fcf26a05db4a2af4797206c113d74da0
MD5 f2faee35dd54660f0a83919b6a5de01c
BLAKE2b-256 f7797192f1f07905ef95a776cf73940e6ffbd76452783733fe35bb3e9b328440

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page