From aa1b2165fa2edf5bd0e469c1437b850327bf87b3 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 27 Mar 2025 20:19:49 +0000 Subject: [PATCH] Add User schema --- schemas/user.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 schemas/user.py diff --git a/schemas/user.py b/schemas/user.py new file mode 100644 index 0000000..d435cd8 --- /dev/null +++ b/schemas/user.py @@ -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 + } + } \ No newline at end of file