From 6a087d88a8bf57fcf7eefe4ef9d2dde1cfc8d4b4 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 17:09:24 +0000 Subject: [PATCH] Add User schema --- schemas/user.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 schemas/user.py diff --git a/schemas/user.py b/schemas/user.py new file mode 100644 index 0000000..f1fb4b8 --- /dev/null +++ b/schemas/user.py @@ -0,0 +1,47 @@ +from pydantic import BaseModel, Field, EmailStr +from typing import Optional +from decimal import Decimal + +class UserBase(BaseModel): + username: str = Field(..., min_length=3, max_length=50) + email: EmailStr = Field(...) + first_name: Optional[str] = Field(None, min_length=1, max_length=50) + last_name: Optional[str] = Field(None, min_length=1, max_length=50) + monthly_budget: Decimal = Field(default=0.0, ge=0) + currency: str = Field(default="USD", min_length=3, max_length=3) + is_active: bool = Field(default=True) + +class UserCreate(UserBase): + password: str = Field(..., min_length=8, max_length=100) + + class Config: + schema_extra = { + "example": { + "username": "johndoe", + "email": "john@example.com", + "password": "securepass123", + "first_name": "John", + "last_name": "Doe", + "monthly_budget": 1000.00, + "currency": "USD", + "is_active": True + } + } + +class UserResponse(UserBase): + id: int = Field(...) + + class Config: + orm_mode = True + schema_extra = { + "example": { + "id": 1, + "username": "johndoe", + "email": "john@example.com", + "first_name": "John", + "last_name": "Doe", + "monthly_budget": 1000.00, + "currency": "USD", + "is_active": True + } + } \ No newline at end of file