[UP] data_models.py
This commit is contained in:
parent
2400dfecc3
commit
e64c1a22a6
1 changed files with 5 additions and 29 deletions
|
|
@ -6,41 +6,17 @@ class User(BaseModel):
|
|||
id: Optional[int] = Field(description="Идентификатор (автоматический)", default=None)
|
||||
username: str = Field(max_length=150, description="Пользовательское имя", example="john_doe")
|
||||
#password: str = Field(max_length=255, description="Пароль", example="secret123")
|
||||
email: str = Field(max_length=254, default="", description="Электронная почта", example="john@example.com")
|
||||
first_name: str = Field(max_length=150, default="", description="Имя", example="John")
|
||||
last_name: str = Field(max_length=150, default="", description="Фамилия", example="Doe")
|
||||
email: Optional[str] = Field(max_length=254, default="", description="Электронная почта", example="john@example.com")
|
||||
first_name: Optional[str] = Field(max_length=150, default="", description="Имя", example="John")
|
||||
last_name: Optional[str] = Field(max_length=150, default="", description="Фамилия", example="Doe")
|
||||
#is_staff: bool = Field(default=False, description="Статус администратора")
|
||||
#is_active: bool = Field(default=False, description="Активен")
|
||||
#is_superuser: bool = Field(default=False, description="Суперпользователь")
|
||||
#date_joined: str = Field(description="Дата создания", example="2024-01-01T12:00:00")
|
||||
#last_login: Optional[str] = Field(null=True, default=None, description="Последний вход")
|
||||
|
||||
@validator("email")
|
||||
def validate_email(cls, v):
|
||||
if v and "@" not in v or "." not in v:
|
||||
raise ValueError("Некорректный email")
|
||||
return v
|
||||
|
||||
@validator("username")
|
||||
def validate_username(cls, v):
|
||||
if len(v) > 150:
|
||||
raise ValueError("Имя пользователя слишком длинное (максимум 150 символов)")
|
||||
return v
|
||||
|
||||
@validator("first_name")
|
||||
def validate_first_name(cls, v):
|
||||
if v and len(v) > 150:
|
||||
raise ValueError("Имя слишком длинное (максимум 150 символов)")
|
||||
return v
|
||||
|
||||
@validator("last_name")
|
||||
def validate_last_name(cls, v):
|
||||
if v and len(v) > 150:
|
||||
raise ValueError("Фамилия слишком длинная (максимум 150 символов)")
|
||||
return v
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
extra = "ignore"
|
||||
from_attributes = True
|
||||
|
||||
|
||||
|
|
@ -118,7 +94,7 @@ class SIPAccount(BaseModel):
|
|||
return v
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
extra = "ignore"
|
||||
from_attributes = True
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue