Add 4 lab code

This commit is contained in:
2026-11-06 17:08:07 +03:00
parent 276dbdad8a
commit 545d083049
38 changed files with 1652 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]