Add third lab code

This commit is contained in:
2026-10-24 01:03:18 +03:00
parent ec540a1a72
commit 4c7a796795
41 changed files with 1581 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
from typing import List, Optional
from pydantic import Field, StrictStr, field_validator
from .common import ContractModel
class CreateChat(ContractModel):
title: StrictStr = Field(min_length=1, max_length=100)
member_ids: List[StrictStr] = Field(min_length=1, max_length=100)
@field_validator("title")
def validate_title(cls, value):
if not value.strip():
raise ValueError("blank title")
return value
@field_validator("member_ids")
def validate_member_ids(cls, value):
if len(value) != len(set(value)):
raise ValueError("duplicate member_ids")
return value
class Chat(ContractModel):
id: str
title: str
member_ids: List[str]
created_at: str
class ChatPage(ContractModel):
items: List[Chat]
next_cursor: Optional[str]