31 lines
566 B
Python
31 lines
566 B
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, EmailStr, Field
|
|
|
|
|
|
class UserCreate(BaseModel):
|
|
username: str = Field(
|
|
min_length=3,
|
|
max_length=50,
|
|
pattern=r"^[a-zA-Z0-9_.-]+$",
|
|
)
|
|
|
|
email: EmailStr
|
|
|
|
password: str = Field(
|
|
min_length=8,
|
|
max_length=128,
|
|
)
|
|
|
|
is_admin: bool = False
|
|
|
|
|
|
class UserResponse(BaseModel):
|
|
id: int
|
|
username: str
|
|
email: EmailStr
|
|
is_active: bool
|
|
is_admin: bool
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True) |