|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- # Purpose: User schema for pydantic (validation, inside-api usage)
-
- from pydantic import BaseModel, EmailStr, Field
- from typing import Optional, List
-
-
- class UserCreate(BaseModel):
- Email: EmailStr
- Password: str = Field(..., min_length=7, max_length=20)
- Name: str = Field(..., min_length=3, max_length=50)
- MiddleName: str = Field(None)
- LastName: str = Field(..., min_length=3, max_length=50)
- ContactNumber: str = Field(..., min_length=12, max_length=12)
- GovernmentId: str = Field(...)
- Address: str = Field(...)
- Email: EmailStr = Field(...)
- Role: str = Field(...)
-
-
- class DriverCreate(UserCreate):
- DrivingLicenseNumber: str = Field(...)
-
-
- class ShowUser(BaseModel):
- Id: int
- Name: str
- MiddleName: str | None
- LastName: str
- ContactNumber: str
- GovernmentId: str
- Address: str
- Email: EmailStr
- Role: str
-
- class Config:
- orm_mode = True
- validate_assignment = True
-
-
- class OutputUser(BaseModel):
- id: int
- Name: str
- MiddleName: Optional[str]
- LastName: str
- ContactNumber: str
- Address: str
- Email: EmailStr
- Role: str
- AssignedVehicle: Optional[
- str
- ] # replace str with the actual type of AssignedVehicle
-
- class Config:
- orm_mode = True
-
-
- class UsersPage(BaseModel):
- users: List[OutputUser]
- total_pages: int
-
-
- class ShowDriverNoVehicle(ShowUser):
- DrivingLicenseNumber: str | None
-
-
- from schemas.vehicle import OutputVehicle
-
-
- class ShowDriver(ShowUser):
- DrivingLicenseNumber: str | None
- AssignedVehicle: OutputVehicle | None
|