2025-06-08 21:57:05 +00:00

48 lines
892 B
Python

"""User schema module."""
from typing import Optional
from pydantic import BaseModel, EmailStr, Field
class UserBase(BaseModel):
"""Base user schema with common attributes."""
email: EmailStr
full_name: Optional[str] = None
is_active: bool = True
is_superuser: bool = False
class UserCreate(UserBase):
"""User creation schema."""
password: str = Field(..., min_length=8)
class UserUpdate(UserBase):
"""User update schema."""
password: Optional[str] = Field(None, min_length=8)
class UserInDBBase(UserBase):
"""Base schema for users in the database."""
id: int
class Config:
"""Pydantic configuration."""
from_attributes = True
class User(UserInDBBase):
"""User schema returned from API calls."""
pass
class UserInDB(UserInDBBase):
"""User schema with hashed password."""
hashed_password: str