-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
50 lines (37 loc) · 1.05 KB
/
models.py
File metadata and controls
50 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from pydantic import BaseModel, validator
from sqlalchemy import Column, Integer, String, Float
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class UserCreate(BaseModel):
edv: int
name: str
sobrenome: str
area: str
@validator('edv')
def validarCode(cls, value):
if len(str(value)) != 8:
raise ValueError('Código Inválido!')
return value
class UserRead(BaseModel):
id: int
edv: int
name: str
sobrenome: str
area: str
class UserUpdate(BaseModel):
edv: int
name: str
sobrenome: str
area: str
@validator('edv')
def validarEdv(cls, value):
if len(str(value)) != 8:
raise ValueError('EDV Inválido!')
return value
class UserDB(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key = True, index=True)
edv = Column(Integer, primary_key = True, index=True)
name = Column(String, index=True)
sobrenome = Column(String, index=True)
area = Column(String, index=True)