-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: create a folder with old documentation (#71)
- Loading branch information
1 parent
5f6669e
commit e19c7be
Showing
4 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# brutils | ||
|
||
### [Procurando pela versão em português?](PORTUGUESE_VERSION.md) | ||
|
||
_Compatible with Python 2.7 and 3.x_ | ||
|
||
`brutils` is a library for validating brazilian document numbers, and might | ||
eventually evolve to deal with other validations related to brazilian bureaucracy. | ||
|
||
It's main functionality is the validation of CPF and CNPJ numbers, but suggestions | ||
for other (preferrably deterministic) things to validate are welcome. | ||
|
||
|
||
## Installation | ||
|
||
``` | ||
pip install brutils | ||
``` | ||
|
||
|
||
## Utilization | ||
|
||
### Importing: | ||
``` | ||
>>> from brutils import cpf, cnpj | ||
``` | ||
|
||
### How do I validate a CPF or CNPJ? | ||
``` | ||
# numbers only, formatted as strings | ||
>>> cpf.validate('00011122233') | ||
False | ||
>>> cnpj.validate('00111222000133') | ||
False | ||
``` | ||
|
||
### What if my string has formatting symbols in it? | ||
``` | ||
>>> cpf.sieve('000.111.222-33') | ||
'00011122233' | ||
>>> cnpj.sieve('00.111.222/0001-00') | ||
'00111222000100' | ||
# The `sieve` function only filters out the symbols used for CPF or CNPJ validation. | ||
# It purposefully doesn't remove other symbols, as those may be indicators of data | ||
# corruption, or a possible lack of input filters. | ||
``` | ||
|
||
### What if I want to format a numbers only string? | ||
``` | ||
>>> cpf.display('00011122233') | ||
'000.111.222-33' | ||
>>> cnpj.display('00111222000100') | ||
'00.111.222/0001-00' | ||
``` | ||
|
||
### What if I want to generate random, but numerically valid CPF or CNPJ numbers? | ||
``` | ||
>>> cpf.generate() | ||
'17433964657' | ||
>>> cnpj.generate() | ||
'34665388000161' | ||
``` | ||
|
||
|
||
## Testing | ||
|
||
``` | ||
python2.7 -m unittest discover tests/ | ||
python3 -m unittest discover tests/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# brutils | ||
|
||
### [Looking for the english version?](ENGLISH_VERSION.md) | ||
|
||
_Compatível com Python 2.7 e 3.x_ | ||
|
||
`brutils` é uma biblioteca para tratar de validações de documentos brasileiros, | ||
e que eventualmente pode evoluir para tratar de outras coisas dentro do escopo | ||
de validações relacionadas a burocracias brasileiras. | ||
|
||
Sua principal funcionalidade é a validação de CPFs e CNPJs, mas sugestões sobre | ||
outras coisas a se validar (preferencialmente de maneira determinística) são bem | ||
vindas. | ||
|
||
|
||
## Instalação | ||
|
||
``` | ||
pip install brutils | ||
``` | ||
|
||
|
||
## Utilização | ||
|
||
### Importando a Biblioteca: | ||
``` | ||
>>> from brutils import cpf, cnpj | ||
``` | ||
|
||
### Como faço para validar um CPF ou CNPJ? | ||
``` | ||
# somente numeros, em formato string | ||
>>> cpf.validate('00011122233') | ||
False | ||
>>> cnpj.validate('00111222000133') | ||
False | ||
``` | ||
|
||
### E se a minha string estiver formatada com simbolos? | ||
``` | ||
>>> cpf.sieve('000.111.222-33') | ||
'00011122233' | ||
>>> cnpj.sieve('00.111.222/0001-00') | ||
'00111222000100' | ||
# A função `sieve` limpa apenas os simbolos de formatação de CPF ou CNPJ, e de | ||
# whitespace nas pontas. Ela não remove outros caractéres propositalmente, pois | ||
# estes seriam indicativos de uma possível corrupção no dado ou de uma falta de | ||
# filtros de input. | ||
``` | ||
|
||
### E se eu quiser formatar uma string numérica? | ||
``` | ||
>>> cpf.display('00011122233') | ||
'000.111.222-33' | ||
>>> cnpj.display('00111222000100') | ||
'00.111.222/0001-00' | ||
``` | ||
|
||
### E se eu quiser gerar CPFs ou CNPJs validos aleatórios? | ||
``` | ||
>>> cpf.generate() | ||
'17433964657' | ||
>>> cnpj.generate() | ||
'34665388000161' | ||
``` | ||
|
||
|
||
## Testes | ||
|
||
``` | ||
python2.7 -m unittest discover tests/ | ||
python3 -m unittest discover tests/ | ||
``` |