[UP] data_models.py
This commit is contained in:
parent
e64c1a22a6
commit
7867b8cf60
1 changed files with 0 additions and 18 deletions
|
|
@ -45,24 +45,6 @@ class SIPAccount(BaseModel):
|
||||||
internal_number: Optional[str] = Field(max_length=255, null=True, blank=True, description="Внутренний номер")
|
internal_number: Optional[str] = Field(max_length=255, null=True, blank=True, description="Внутренний номер")
|
||||||
endpoint_name: Optional[str] = Field(max_length=255, null=True, blank=True, description="Имя конечной точки")
|
endpoint_name: Optional[str] = Field(max_length=255, null=True, blank=True, description="Имя конечной точки")
|
||||||
|
|
||||||
@validator("server_url")
|
|
||||||
def validate_server_url(cls, v):
|
|
||||||
if not v:
|
|
||||||
return v
|
|
||||||
# Проверяем, содержит ли строка URL (в формате http:// или https://)
|
|
||||||
if v.startswith("http://") or v.startswith("https://"):
|
|
||||||
return v
|
|
||||||
# Проверяем, является ли это IPv4 (простая проверкаDetails)
|
|
||||||
parts = v.strip().split(':')
|
|
||||||
if len(parts) == 1:
|
|
||||||
ip_part = parts[0]
|
|
||||||
if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", ip_part):
|
|
||||||
# Проверяем, что каждая часть от 0 до 255
|
|
||||||
ip_parts = [int(x) for x in ip_part.split('.')]
|
|
||||||
if all(0 <= part <= 255 for part in ip_parts):
|
|
||||||
return v
|
|
||||||
raise ValueError("Invalid server URL format (must be http(s):// or IPv4 address)")
|
|
||||||
|
|
||||||
@validator("username")
|
@validator("username")
|
||||||
def validate_username(cls, v):
|
def validate_username(cls, v):
|
||||||
if len(v) > 40:
|
if len(v) > 40:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue