69 lines
1.5 KiB
Python
69 lines
1.5 KiB
Python
# Importações de bibliotecas padrão
|
|
import re
|
|
from typing import List
|
|
from uuid import UUID
|
|
|
|
# Importações de bibliotecas de terceiros
|
|
from pydantic import BaseModel, field_validator, EmailStr, ConfigDict
|
|
|
|
|
|
class Papeis(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
uuid: UUID
|
|
|
|
|
|
class PapeisResponse(Papeis):
|
|
nome: str
|
|
|
|
|
|
class UsuarioBase(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
username: str
|
|
full_name: str
|
|
email: EmailStr
|
|
papeis: List[Papeis]
|
|
|
|
# @field_validator('username')
|
|
# def validate_username(cls, value):
|
|
# if not re.match('^([a-z]|[0-9]|@)+$', value):
|
|
# raise ValueError('Username format invalid')
|
|
# return value
|
|
|
|
|
|
class UsuarioCreate(UsuarioBase):
|
|
password: str
|
|
|
|
|
|
class UsuarioResponse(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
username: str
|
|
full_name: str
|
|
email: EmailStr
|
|
papeis: List[PapeisResponse]
|
|
|
|
# @field_validator('username')
|
|
# def validate_username(cls, value):
|
|
# if not re.match('^([a-z]|[0-9]|@)+$', value):
|
|
# raise ValueError('Username format invalid')
|
|
# return value
|
|
|
|
|
|
class UsuarioRequest(UsuarioBase):
|
|
pass
|
|
|
|
|
|
class UsuarioLogin(BaseModel):
|
|
username: str
|
|
password: str
|
|
|
|
# @field_validator('username')
|
|
# def validate_username(cls, value):
|
|
# if not re.match('^([a-z]|[0-9]|@)+$', value):
|
|
# raise ValueError('Username format invalid')
|
|
# return value
|
|
|
|
|
|
class Token(BaseModel):
|
|
access_token: str
|
|
token_type: str
|