Add User schema
This commit is contained in:
parent
d8031652d9
commit
a9e2357ddb
40
schemas/user.py
Normal file
40
schemas/user.py
Normal file
@ -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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user