Add User schema

This commit is contained in:
Backend IM Bot 2025-03-26 16:27:58 +00:00
parent c8a246bb5c
commit f0b03ddbc8

34
schemas/user.py Normal file
View File

@ -0,0 +1,34 @@
from pydantic import BaseModel, Field, EmailStr
from typing import Optional
class UserBase(BaseModel):
username: str = Field(..., min_length=3, max_length=50)
email: EmailStr = Field(...)
full_name: str = Field(..., min_length=1, max_length=100)
class UserCreate(UserBase):
password: str = Field(..., min_length=8, max_length=100)
class Config:
schema_extra = {
"example": {
"username": "johndoe",
"email": "john@example.com",
"full_name": "John Doe",
"password": "securepass123"
}
}
class UserResponse(UserBase):
is_active: bool = True
class Config:
orm_mode = True
schema_extra = {
"example": {
"username": "johndoe",
"email": "john@example.com",
"full_name": "John Doe",
"is_active": True
}
}