Files
mtusi2026labs/src/messenger/messaging/domain/values.py
T
ArtyomandClaude Opus 5.5 bf8e4e3cd1 Carry over the lab 3 solution
Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy and k6 configuration, migrations, hooks, evidence and level 4
scripts and the CI job from the lab 3 solution commit 61c0c28, merge
the lab 3 Makefile targets into the lab 4 skeleton Makefile without
touching its targets, and append the lab 3 solution variables to the
skeleton .env.example. The package and the application follow the
contract version 1.4.0, and the image and the throwaway test containers
are tagged lab4 so they do not collide with a lab 3 stand on the same
host.

This is the starting point of the lab 4 cycle: lint, own tests and the
offline skeleton check pass before any lab 4 change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-28 20:17:51 +03:00

40 lines
1.4 KiB
Python

from dataclasses import dataclass
from messenger.messaging.domain.errors import InvalidChatData, InvalidMessageText
CHAT_TITLE_MAX = 100
MESSAGE_TEXT_MAX = 4000
CHAT_MEMBERS_MAX = 100
@dataclass(frozen=True, slots=True)
class ChatTitle:
value: str
def __post_init__(self) -> None:
if not isinstance(self.value, str):
raise InvalidChatData("поле title должно быть строкой")
if not self.value.strip():
raise InvalidChatData("поле title не может быть пустым или состоять из пробелов")
if len(self.value) > CHAT_TITLE_MAX:
raise InvalidChatData(f"поле title длиннее {CHAT_TITLE_MAX} символов Unicode")
def __str__(self) -> str:
return self.value
@dataclass(frozen=True, slots=True)
class MessageText:
value: str
def __post_init__(self) -> None:
if not isinstance(self.value, str):
raise InvalidMessageText("поле text должно быть строкой")
if not self.value.strip():
raise InvalidMessageText("поле text не может быть пустым или состоять из пробелов")
if len(self.value) > MESSAGE_TEXT_MAX:
raise InvalidMessageText(f"поле text длиннее {MESSAGE_TEXT_MAX} символов Unicode")
def __str__(self) -> str:
return self.value