Library for validation and formatting of Brazilian data
Project description
Validator Brazil
Python library for validation and formatting of Brazilian data such as:
- CPF
- CNPJ
- Vehicle license plates.
- Postal codes (CEP) # TODO
- Phone numbers # TODO
Installation
pip install br-eval
Usage example
CPF
from br_eval.cpf import validate_cpf, format_cpf
# Validate CPF
try:
validate_cpf('145.382.206-20')
print("CPF is valid.")
except Exception as e:
print(f"Invalid CPF: {e}")
# Format CPF
formatted_cpf = format_cpf('14538220620')
print(f"Formatted CPF: {formatted_cpf}")
CNPJ example
from validator_brazil import validate_cnpj, format_cnpj
# Validate CNPJ
try:
validate_cnpj('13.347.016/0001-17')
print("CNPJ is valid.")
except Exception as e:
print(f"Invalid CNPJ: {e}")
# Format CNPJ
formatted_cnpj = format_cnpj('13347016000117')
print(f"Formatted CNPJ: {formatted_cnpj}")
Plate example
from validator_brazil import validate_plate, format_plate
# Validate Plate
try:
plate_type = validate_plate('ABC1234')
print(f"Plate is valid. Type: {plate_type}")
except Exception as e:
print(f"Invalid plate: {e}")
# Validate Mercosul Car Plate
try:
plate_type = validate_plate('ABC1D23')
print(f"Plate is valid. Type: {plate_type}")
except Exception as e:
print(f"Invalid plate: {e}")
# Validate Mercosul Motorcycle Plate
try:
plate_type = validate_plate('ABC12D3')
print(f"Plate is valid. Type: {plate_type}")
except Exception as e:
print(f"Invalid plate: {e}")
# Format Plate
formatted_plate = format_plate('ABC1D23')
print(f"Formatted Plate: {formatted_plate}") # Output: 'ABC-1D23'
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
IMPORTANT NOTICE
Disclaimer 1: The CPF and CNPJ generator functions provided by this library are intended solely for development and testing purposes. The generated numbers do not correspond to real individuals or companies and should not be used in production systems, official registrations, or for any illegal or fraudulent activities. Misuse of these functions is the sole responsibility of the user.
Disclaimer 2: The vehicle plate generator functions provided in this library are intended solely for development and testing purposes. The generated plates do not correspond to real vehicles and should not be used in production systems, official documents, registrations, or any activities involving real-world entities. Misuse of these functions is the sole responsibility of the user.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file br-eval-0.4.3.tar.gz.
File metadata
- Download URL: br-eval-0.4.3.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50eebc3890fe41730a5f45bd69dca08fab4b450c7ac245d4fa934b1ecc763a01
|
|
| MD5 |
69b2263a8097482834a8a0799d0a03ad
|
|
| BLAKE2b-256 |
c08005a88632dfd073e441e6c75df6855ae7500a65f9497a7fe9a0d90b325eac
|
File details
Details for the file br_eval-0.4.3-py3-none-any.whl.
File metadata
- Download URL: br_eval-0.4.3-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8729f331c034df9309f2f79cbff5e04fc6eceebd946a8a7c96bb217234bfce73
|
|
| MD5 |
01af31dd28cf7b3453dfe2b44c8c940f
|
|
| BLAKE2b-256 |
0246081a945f72692e125b34ab9be824ddf09563868556634b5db0e2157cfbd3
|