Skip to main content

A simple Python library containing functions that check Brazilian documents values

Project description

GitHub license

Project description

A simple Python library containing functions that check Brazilian documents values. It is intended to make it easy to verify CNPJ and CPF numbers. Originally developed and open-sourced at Sliatecinos (GitHub).

Installation

pip install br-registrations

Basic Usage

from br_registrations import validateCPF, validateCNPJ

# Validation test of registration CPF number
# Instances the validation
cpf=validateCPF.CPF
# Passing a 11-digit number of CPF (in string format):
response_1=cpf.valid_cpf('11144477735')
response_2=cpf.valid_cpf('912.441.670-37', True)
response_3=cpf.valid_cpf('11111111111', True)
# Outputs #1, #2: 'CPF ___ is valid is True .'
print('CPF "11144477735" is valid is', response_1, '.')
print('CPF "912.441.670-37" is valid is', response_2, '.')
# Outputs #3: 'CPF ___ is valid is False .'
print('CPF "11111111111" is valid is', response_3, '.')

# Passing a registration number of CPF (in string format):
dv_1=cpf.get_cpf_dv('111444777')
dv_2=cpf.get_cpf_dv('912.441.670', True)
# Output (in list): 'Correct DV:  [3, 5]'
print('Correct DV: ', dv_1)
# Output (in list): 'Correct DV:  [3, 7]'
print('Correct DV: ', dv_2)

print('='*100)

# Validation test of registration CNPJ number
# Instances the validation:
cnpj=validateCNPJ.CNPJ
# Passing a 14-digit number of CNPJ (in string format):
response_1=cnpj.valid_cnpj('11222333000181')
response_2=cnpj.valid_cnpj('46.293.332/0001-02', True)
response_3=cnpj.valid_cnpj('11111111111111')
# Outputs #1, #2: 'CNPJ ___ is valid is True .'
print('CNPJ "11222333000181" is valid is', response_1, '.')
print('CNPJ "46.293.332/0001-02" is valid is', response_2, '.')
# Outputs #3: 'CNPJ ___ is valid is False .'
print('CNPJ "11111111111111" is valid is', response_3, '.')

# Passing a registration number of CNPJ (in string format):
dv_1=cnpj.get_cnpj_dv('112223330001')
dv_2=cnpj.get_cnpj_dv('46.293.332/0001', True)
# Output #1 (in list): 'Correct DV:  [8, 1]'
print('Correct DV: ', dv_1)
# Output #2 (in list): 'Correct DV:  [0, 2]'
print('Correct DV: ', dv_2)

# View lib version:
import br_registrations as brr
print(brr.__version__)

License

The project is made available under the terms of the MIT license. See LICENSE for details.

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

br_registrations-0.0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

br_registrations-0.0.1.0-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file br_registrations-0.0.1.0.tar.gz.

File metadata

  • Download URL: br_registrations-0.0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for br_registrations-0.0.1.0.tar.gz
Algorithm Hash digest
SHA256 7863aa69e18c4fd261b260275cfafa7f0ec2aaad70250cc1934e6c2806afa042
MD5 e0839842c9d938287f5916e4537151e3
BLAKE2b-256 d4aa81ca96ef6d5b05b2db559978e597b44348c33b0834c2334dee02727d5dbd

See more details on using hashes here.

File details

Details for the file br_registrations-0.0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: br_registrations-0.0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for br_registrations-0.0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7dd3202d8f5b0befc26f2f3fbecb640c413c2f5eb703d85c994f2717a2ceba05
MD5 401a702897e2bb9ce9f9385a5d8779d4
BLAKE2b-256 324bced28044df0f2681ce478ad1cde13515029b6b2764380db556f759e04779

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