|
1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
2
|
|
|
# ############################################################################# |
|
3
|
|
|
# |
|
4
|
|
|
# The MIT License (MIT) |
|
5
|
|
|
# |
|
6
|
|
|
# Copyright (c) 2016 Trocafone |
|
7
|
|
|
# |
|
8
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
9
|
|
|
# of this software and associated documentation files (the "Software"), to deal |
|
10
|
|
|
# in the Software without restriction, including without limitation the rights |
|
11
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12
|
|
|
# copies of the Software, and to permit persons to whom the Software is |
|
13
|
|
|
# furnished to do so, subject to the following conditions: |
|
14
|
|
|
# |
|
15
|
|
|
# The above copyright notice and this permission notice shall be included in |
|
16
|
|
|
# all copies or substantial portions of the Software. |
|
17
|
|
|
# |
|
18
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
19
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
20
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
21
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
22
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
23
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
24
|
|
|
# SOFTWARE. |
|
25
|
|
|
# |
|
26
|
|
|
############################################################################### |
|
27
|
|
|
|
|
28
|
1 |
|
from correios_lib.base import EntityBase |
|
29
|
1 |
|
from voluptuous import Schema, Required, All, Length, Optional |
|
|
|
|
|
|
30
|
1 |
|
from correios_lib.validators import CEP, Email |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
1 |
|
class Pessoa(EntityBase): |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
1 |
|
def get_schema(self): |
|
36
|
1 |
|
return Schema({ |
|
37
|
|
|
Required('nome'): All(str, Length(min=4)), |
|
38
|
|
|
Required('logradouro'): All(str, Length(min=4)), |
|
39
|
|
|
Required('numero'): All(str, Length(min=1)), |
|
40
|
|
|
Optional('complemento'): str, |
|
41
|
|
|
Required('bairro'): All(str, Length(min=2)), |
|
42
|
|
|
Optional('referencia'): str, |
|
43
|
|
|
Required('cidade'): All(str, Length(min=3)), |
|
44
|
|
|
Required('uf'): All(str, Length(min=2, max=2)), |
|
45
|
|
|
Required('cep'): All(CEP, Length(min=8, max=9)), |
|
46
|
|
|
Optional('ddd'): All(str, Length(min=2, max=2)), |
|
47
|
|
|
Optional('telefone'): All(str, Length(min=8, max=10)), |
|
48
|
|
|
Optional('email'): Email |
|
49
|
|
|
}) |
|
50
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.