Add second lab code

This commit is contained in:
2026-10-23 15:12:43 +03:00
parent 0ab3a341aa
commit cd9c3402fa
40 changed files with 1692 additions and 10 deletions
+29
View File
@@ -0,0 +1,29 @@
from typing import List, Optional
from pydantic import Field, StrictStr, field_validator
from .common import ContractModel
class CreateMessage(ContractModel):
text: StrictStr = Field(min_length=1, max_length=4000)
@field_validator("text")
def validate_text(cls, value):
if not value.strip():
raise ValueError("blank text")
return value
class Message(ContractModel):
id: str
chat_id: str
sender_id: str
text: str
created_at: str
class MessagePage(ContractModel):
items: List[Message]
next_cursor: Optional[str]