Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
144 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.idea/* | ||
venv/* | ||
validate_docbr/__pycache__/* | ||
dist/* | ||
build/* | ||
build/* | ||
validate_docbr/__pycache__/* | ||
site/* |
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,80 @@ | ||
# Guia de uso | ||
Todos os documentos possuem os mesmos métodos e funcionam da mesma forma. | ||
|
||
## Métodos | ||
A seguir você verá a descrição e exemplos de como usar os métodos de cada classe. | ||
|
||
------------ | ||
### validate | ||
Valida o documento passado como argumento. Retorna um `bool`, `True` caso seja válido, `False` caso contrário . Recebe os parâmetros: | ||
|
||
| Parâmetro | Tipo | Valor padrão | Obrigatório | Descrição | | ||
| --------- | ---- | ----------- | ------------ | --------- | | ||
| `doc` | `str`| `''` | X | O documento que se quer validar. | | ||
|
||
```python | ||
from validate_docbr import CPF | ||
|
||
cpf = CPF() | ||
|
||
# Validar CPF | ||
cpf.validate("012.345.678-90") # True | ||
cpf.validate("012.345.678-91") # False | ||
``` | ||
|
||
------------ | ||
### generate | ||
Gera um novo documento, retorna em formato de `str`. Recebe os parâmetros: | ||
|
||
| Parâmetro | Tipo | Valor padrão | Obrigatório | Descrição | | ||
| --------- | ---- | ----------- | ------------ | --------- | | ||
| `mask` | `bool` | `False` | - | Quando possui o valor `True`, o documento retornado estará formatado. | | ||
|
||
```python | ||
from validate_docbr import CPF | ||
|
||
cpf = CPF() | ||
|
||
# Gerar novo CPF | ||
new_cpf_one = cpf.generate() # "01234567890" | ||
new_cpf_two = cpf.generate(True) # "012.345.678-90" | ||
``` | ||
|
||
------------ | ||
### generate_list | ||
Gera uma lista de documentos, retorna em formato de `list` com elementos do tipo `str`. Recebe os parâmetros: | ||
|
||
| Parâmetro | Tipo | Valor padrão | Obrigatório | Descrição | | ||
| --------- | ---- | ----------- | ------------ | --------- | | ||
| `n` | `int` | `1` | X | A quantidade desejada de documentos que serão gerados. | | ||
| `mask` | `bool` | `False` | - | Se os documentos gerados deverão ter ou não máscara. | | ||
| `repeat` | `bool` | `False` | - | Se aceita ou não documentos repetidos. | | ||
|
||
```python | ||
from validate_docbr import CPF | ||
|
||
cpf = CPF() | ||
|
||
# Gerar lista de CPFs | ||
cpfs_one = cpf.generate_list(2) # [ "85215667438", "28293145811" ] | ||
cpfs_two = cpf.generate_list(2, True) # [ "852.156.674-38", "282.931.458-11" ] | ||
``` | ||
|
||
------------ | ||
### mask | ||
Mascara o documento passado como argumento. Retorna um `str` que é o documento mascarado . Recebe os parâmetros: | ||
|
||
| Parâmetro | Tipo | Valor padrão | Obrigatório | Descrição | | ||
| --------- | ---- | ----------- | ------------ | --------- | | ||
| `doc` | `str`| `''` | X | O documento que se quer mascarar. | | ||
|
||
```python | ||
from validate_docbr import CPF | ||
|
||
cpf = CPF() | ||
|
||
cpf_me = "01234567890" | ||
|
||
# Mascara o CPF | ||
cpf.mask(cpf_me) # "012.345.678-90" | ||
``` |
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,14 @@ | ||
# validate-docbr | ||
<a href="https://pypi.org/project/validate-docbr/"> | ||
<img src="https://img.shields.io/pypi/v/validate-docbr.svg" alt="latest release" /> | ||
</a> | ||
|
||
Pacote Python para validação de documentos brasileiros. | ||
|
||
## Instalação do MRE | ||
|
||
Para instalar o pacote: | ||
|
||
```bash | ||
pip install validate-docbr | ||
``` |
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,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2018 The Python Packaging Authority | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,8 @@ | ||
Pacote Python para validação de documentos brasileiros. | ||
|
||
## Documentos | ||
Documentos que estão no pacote: | ||
|
||
- CPF: Cadastro de Pessoas Físicas; | ||
- CNPJ: Cadastro Nacional da Pessoa Jurídica; | ||
- CNS: Cartão Nacional de Saúde. |
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,14 @@ | ||
site_name: validate-docbr | ||
site_url: https://github.com/alvarofpp/validate-docbr | ||
site_description: Pacote Python para validação de documentos brasileiros. | ||
site_author: MkDocs Team | ||
|
||
nav: | ||
- Instalação: index.md | ||
- Guia de uso: guia-de-uso.md | ||
- Sobre: sobre.md | ||
- Licença: licenca.md | ||
|
||
repo_url: https://github.com/alvarofpp/validate-docbr | ||
|
||
theme: readthedocs |
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 |
---|---|---|
|
@@ -11,3 +11,6 @@ | |
|
||
for i in cpfs: | ||
assert cpf.validate(i) | ||
|
||
cpf_me = "01234567890" | ||
assert cpf.mask(cpf_me) == "012.345.678-90" |