Files
mtusi2026lab6/src/messenger/messaging/domain/values.py
T
ArtyomandClaude Opus 5.5 5ae3d77152 Carry over the lab 5 solution
Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks,
scenario scripts and the CI job from the lab 5 solution commit 64d5c67,
keep the lab 5 Makefile targets on top of the unchanged skeleton
targets, and append the lab 5 solution variables to the skeleton
.env.example. The package and the application follow the contract
version 1.6.0, and the image, the throwaway test containers and the
broker vhost description are tagged lab6 so they do not collide with a
lab 5 stand on the same host.

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

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

41 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
MESSAGE_ATTACHMENTS_MAX = 10
@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 self.value and 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