Add User schema
This commit is contained in:
parent
301ad1a756
commit
ce76dd64ab
@ -1,22 +1,22 @@
|
|||||||
from pydantic import BaseModel, Field, EmailStr
|
from pydantic import BaseModel, EmailStr, Field
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
class UserBase(BaseModel):
|
class UserBase(BaseModel):
|
||||||
first_name: str = Field(..., min_length=2, max_length=50)
|
first_name: str = Field(..., min_length=2, max_length=50)
|
||||||
last_name: str = Field(..., min_length=2, max_length=50)
|
last_name: str = Field(..., min_length=2, max_length=50)
|
||||||
email: EmailStr = Field(..., description="User's email address")
|
email: EmailStr = Field(..., description="User email address")
|
||||||
role: str = Field(default="student")
|
role: str = Field(default="student")
|
||||||
grade_level: Optional[int] = Field(None)
|
grade_level: Optional[int] = None
|
||||||
student_id: str = Field(..., min_length=5, max_length=20)
|
student_id: Optional[str] = None
|
||||||
phone_number: Optional[str] = Field(None, max_length=20)
|
phone_number: Optional[str] = None
|
||||||
address: Optional[str] = Field(None, max_length=200)
|
address: Optional[str] = None
|
||||||
date_of_birth: Optional[datetime] = None
|
date_of_birth: Optional[datetime] = None
|
||||||
profile_picture: Optional[str] = None
|
profile_picture: Optional[str] = None
|
||||||
|
|
||||||
class UserCreate(UserBase):
|
class UserCreate(UserBase):
|
||||||
password: str = Field(..., min_length=8, max_length=100)
|
password: str = Field(..., min_length=8, max_length=100)
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
schema_extra = {
|
schema_extra = {
|
||||||
"example": {
|
"example": {
|
||||||
@ -24,12 +24,13 @@ class UserCreate(UserBase):
|
|||||||
"last_name": "Doe",
|
"last_name": "Doe",
|
||||||
"email": "john.doe@example.com",
|
"email": "john.doe@example.com",
|
||||||
"password": "securepass123",
|
"password": "securepass123",
|
||||||
"student_id": "STU123456",
|
"role": "student",
|
||||||
"grade_level": 10,
|
"grade_level": 10,
|
||||||
"phone_number": "+1234567890",
|
"student_id": "STU123",
|
||||||
"address": "123 Main St, City, Country",
|
"phone_number": "123-456-7890",
|
||||||
|
"address": "123 Main St",
|
||||||
"date_of_birth": "2000-01-01T00:00:00",
|
"date_of_birth": "2000-01-01T00:00:00",
|
||||||
"profile_picture": "https://example.com/profile.jpg"
|
"profile_picture": "profile.jpg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,12 +48,12 @@ class UserResponse(UserBase):
|
|||||||
"last_name": "Doe",
|
"last_name": "Doe",
|
||||||
"email": "john.doe@example.com",
|
"email": "john.doe@example.com",
|
||||||
"role": "student",
|
"role": "student",
|
||||||
"student_id": "STU123456",
|
|
||||||
"grade_level": 10,
|
"grade_level": 10,
|
||||||
"phone_number": "+1234567890",
|
"student_id": "STU123",
|
||||||
"address": "123 Main St, City, Country",
|
"phone_number": "123-456-7890",
|
||||||
|
"address": "123 Main St",
|
||||||
"date_of_birth": "2000-01-01T00:00:00",
|
"date_of_birth": "2000-01-01T00:00:00",
|
||||||
"profile_picture": "https://example.com/profile.jpg",
|
"profile_picture": "profile.jpg",
|
||||||
"is_active": True,
|
"is_active": True,
|
||||||
"last_login": "2023-01-01T12:00:00"
|
"last_login": "2023-01-01T12:00:00"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user