You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

72 regels
1.5 KiB

  1. # Purpose: User schema for pydantic (validation, inside-api usage)
  2. from pydantic import BaseModel, EmailStr, Field
  3. from typing import Optional, List
  4. class UserCreate(BaseModel):
  5. Email: EmailStr
  6. Password: str = Field(..., min_length=7, max_length=20)
  7. Name: str = Field(..., min_length=3, max_length=50)
  8. MiddleName: str = Field(None)
  9. LastName: str = Field(..., min_length=3, max_length=50)
  10. ContactNumber: str = Field(..., min_length=6, max_length=16)
  11. GovernmentId: str = Field(...)
  12. Address: str = Field(...)
  13. Email: EmailStr = Field(...)
  14. Role: str = Field(...)
  15. class DriverCreate(UserCreate):
  16. DrivingLicenseNumber: str = Field(...)
  17. class ShowUser(BaseModel):
  18. Id: int
  19. Name: str
  20. MiddleName: str | None
  21. LastName: str
  22. ContactNumber: str
  23. GovernmentId: str
  24. Address: str
  25. Email: EmailStr
  26. Role: str
  27. class Config:
  28. orm_mode = True
  29. validate_assignment = True
  30. class OutputUser(BaseModel):
  31. id: int
  32. Name: str
  33. MiddleName: Optional[str]
  34. LastName: str
  35. ContactNumber: str
  36. Address: str
  37. Email: EmailStr
  38. Role: str
  39. AssignedVehicle: Optional[
  40. str
  41. ] # replace str with the actual type of AssignedVehicle
  42. class Config:
  43. orm_mode = True
  44. class UsersPage(BaseModel):
  45. users: List[OutputUser]
  46. total_pages: int
  47. class ShowDriverNoVehicle(ShowUser):
  48. DrivingLicenseNumber: str | None
  49. from schemas.vehicle import OutputVehicle
  50. class ShowDriver(ShowUser):
  51. DrivingLicenseNumber: str | None
  52. AssignedVehicle: OutputVehicle | None