Spaces:
Sleeping
Sleeping
File size: 2,166 Bytes
0225ffc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | from pydantic import BaseModel, EmailStr, Field
from typing import Optional
class CreateUser(BaseModel):
"""
Schema for registering a new user.
"""
fullName: str = Field(
...,
description="The user's full name.",
example="Vashu The Great"
)
email: EmailStr = Field(
...,
description="A unique email address used for login and notifications.",
example="vashu@example.com"
)
password: str = Field(
...,
description="The secret password. Must be strong.",
example="supersecret123"
)
username: str = Field(
...,
description="A unique alphanumeric username for the profile URL.",
example="vashu_dev"
)
class Config:
json_schema_extra = {
"example": {
"fullName": "Jane Doe",
"email": "jane@example.com",
"password": "mypassword123",
"username": "janedoe"
}
}
class UpdateUser(BaseModel):
"""
Schema for updating basic user profile information.
"""
fullName: Optional[str] = Field(
None,
description="New full name override.",
example="Jane Smith"
)
username: Optional[str] = Field(
None,
description="New username override. Will fail if the new username is already taken.",
example="janesmith"
)
class Config:
json_schema_extra = {
"example": {
"fullName": "Jane Smith",
"username": "janesmith"
}
}
class LoginUser(BaseModel):
"""
Schema for user authentication/login.
"""
email: str = Field(
...,
description="The email address associated with the user account.",
example="vashu@example.com"
)
password: str = Field(
...,
description="The plaintext password to verify.",
example="supersecret123"
)
class Config:
json_schema_extra = {
"example": {
"email": "vashu@example.com",
"password": "supersecret123"
}
} |