From a9e2357ddb3be9a6895a23b33dd62025ac5ae7de Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 27 Mar 2025 16:11:07 +0000 Subject: [PATCH] Add User schema --- schemas/user.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 schemas/user.py diff --git a/schemas/user.py b/schemas/user.py new file mode 100644 index 0000000..8597014 --- /dev/null +++ b/schemas/user.py @@ -0,0 +1,40 @@ +from pydantic import BaseModel, Field, EmailStr +from typing import Optional + +class UserBase(BaseModel): + email: EmailStr = Field(..., description="User's email address") + username: str = Field(..., min_length=3, max_length=50, description="User's username") + first_name: Optional[str] = Field(None, description="User's first name") + last_name: Optional[str] = Field(None, description="User's last name") + is_active: bool = Field(default=True, description="User's active status") + is_verified: bool = Field(default=False, description="User's verification status") + +class UserCreate(UserBase): + password: str = Field(..., min_length=8, max_length=100, description="User's password") + + class Config: + schema_extra = { + "example": { + "email": "user@example.com", + "username": "username123", + "password": "strongpassword123", + "first_name": "John", + "last_name": "Doe", + "is_active": True, + "is_verified": False + } + } + +class UserResponse(UserBase): + class Config: + orm_mode = True + schema_extra = { + "example": { + "email": "user@example.com", + "username": "username123", + "first_name": "John", + "last_name": "Doe", + "is_active": True, + "is_verified": False + } + } \ No newline at end of file