25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
915 B

  1. # Purpose: User schema for pydantic (validation, inside-api usage)
  2. from datetime import datetime
  3. from pydantic import BaseModel, EmailStr, Field
  4. from typing import Optional
  5. class UserCreate(BaseModel):
  6. Email: EmailStr
  7. Password: str = Field(..., min_length=7, max_length=20)
  8. Name: str = Field(..., min_length=3, max_length=50)
  9. MiddleName: str = Field(None, min_length=3, max_length=50)
  10. LastName: str = Field(..., min_length=3, max_length=50)
  11. ContactNumber: str = Field(..., min_length=12, max_length=12)
  12. BirthDate: datetime = Field(...)
  13. Email: EmailStr = Field(...)
  14. Role: str = Field(..., min_length=3, max_length=50)
  15. class ShowUser(BaseModel):
  16. Id: int
  17. Name: str
  18. MiddleName: str | None
  19. LastName: str
  20. ContactNumber: str
  21. BirthDate: datetime
  22. Email: EmailStr
  23. Role: str
  24. class Config:
  25. orm_mode = True
  26. validate_assignment = True