- Add max_length constraints to all string fields in request schemas, matching DB column limits (title:255, description:5000, etc.) - Add min_length=1 to required name/title fields - Add ConfigDict(extra="forbid") to all request schemas to reject unknown fields (prevents silent field injection) - Add Path(ge=1, le=2147483647) to all integer path parameters across all routers to prevent integer overflow → 500 errors - Add max_length to TOTP inline schemas (code:6, mfa_token:256, etc.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
776 B
Python
32 lines
776 B
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
|
|
class CalendarCreate(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
name: str = Field(min_length=1, max_length=100)
|
|
color: str = Field("#3b82f6", max_length=20)
|
|
|
|
|
|
class CalendarUpdate(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
color: Optional[str] = Field(None, max_length=20)
|
|
is_visible: Optional[bool] = None
|
|
|
|
|
|
class CalendarResponse(BaseModel):
|
|
id: int
|
|
name: str
|
|
color: str
|
|
is_default: bool
|
|
is_system: bool
|
|
is_visible: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|