forked from mtusi2026/mtusi2026lab3
Add second lab code
This commit is contained in:
@@ -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]
|
||||
Reference in New Issue
Block a user