- 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>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
|
|
class EventTemplateCreate(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
name: str = Field(min_length=1, max_length=255)
|
|
title: str = Field(min_length=1, max_length=255)
|
|
description: Optional[str] = Field(None, max_length=5000)
|
|
calendar_id: Optional[int] = None
|
|
recurrence_rule: Optional[str] = Field(None, max_length=5000)
|
|
all_day: bool = False
|
|
location_id: Optional[int] = None
|
|
is_starred: bool = False
|
|
|
|
|
|
class EventTemplateUpdate(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
name: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
title: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
description: Optional[str] = Field(None, max_length=5000)
|
|
calendar_id: Optional[int] = None
|
|
recurrence_rule: Optional[str] = Field(None, max_length=5000)
|
|
all_day: Optional[bool] = None
|
|
location_id: Optional[int] = None
|
|
is_starred: Optional[bool] = None
|
|
|
|
|
|
class EventTemplateResponse(BaseModel):
|
|
id: int
|
|
name: str
|
|
title: str
|
|
description: Optional[str]
|
|
calendar_id: Optional[int]
|
|
recurrence_rule: Optional[str]
|
|
all_day: bool
|
|
location_id: Optional[int]
|
|
is_starred: bool
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|