Add User schema
This commit is contained in:
parent
ad36f08619
commit
aa1b2165fa
34
schemas/user.py
Normal file
34
schemas/user.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
from pydantic import BaseModel, Field, EmailStr
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
class UserBase(BaseModel):
|
||||||
|
name: str = Field(..., min_length=1, max_length=100, description="User's full name")
|
||||||
|
address: str = Field(..., min_length=1, max_length=200, description="User's address")
|
||||||
|
phone: Optional[str] = Field(None, max_length=20, description="User's phone number")
|
||||||
|
email: EmailStr = Field(..., description="User's email address")
|
||||||
|
is_active: bool = Field(default=True, description="User's active status")
|
||||||
|
|
||||||
|
class UserCreate(UserBase):
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "John Doe",
|
||||||
|
"address": "123 Main St, City, Country",
|
||||||
|
"phone": "+1234567890",
|
||||||
|
"email": "john@example.com",
|
||||||
|
"is_active": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserResponse(UserBase):
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "John Doe",
|
||||||
|
"address": "123 Main St, City, Country",
|
||||||
|
"phone": "+1234567890",
|
||||||
|
"email": "john@example.com",
|
||||||
|
"is_active": True
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user