Add User schema

This commit is contained in:
Backend IM Bot 2025-03-26 18:04:53 +01:00
parent 5b3e61dfd1
commit 333373f75e

26
schemas/user.py Normal file
View File

@ -0,0 +1,26 @@
from pydantic import BaseModel, Field, EmailStr
class UserBase(BaseModel):
username: str = Field(..., min_length=3, max_length=50, index=True, unique=True, description="User's username")
email: EmailStr = Field(..., unique=True, description="User's email address")
password: str = Field(..., min_length=8, description="User's password")
is_active: bool = Field(True, description="Whether the user account is active")
class Config:
schema_extra = {
"example": {
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword123",
"is_active": True
}
}
class UserCreate(UserBase):
pass
class UserResponse(UserBase):
id: int = Field(..., description="User's unique identifier")
class Config:
orm_mode = True