subul / backend /schemas /user.py
Kaadan's picture
initial commit
358dfff
from typing import Optional
from pydantic import BaseModel, EmailStr, Field
from .base import BaseSchema
from .enums import UserRole
class UserBase(BaseSchema):
first_name: str = Field(..., min_length=1, max_length=50)
last_name: str = Field(..., min_length=1, max_length=50)
email: EmailStr
role: UserRole
class UserCreate(UserBase):
password: str
class UserLogin(BaseModel):
email: EmailStr
password: str
class UserLogout(BaseModel):
pass
class UserUpdate(BaseModel):
first_name: Optional[str] = Field(None, min_length=1, max_length=50)
last_name: Optional[str] = Field(None, min_length=1, max_length=50)
email: Optional[EmailStr] = None
role: Optional[UserRole] = None
class UserResponse(UserBase):
id: str
class Config:
from_attributes = True
class TokenResponse(BaseModel):
token: str