- 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>
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
from datetime import datetime
|
|
from typing import Literal, Optional
|
|
|
|
|
|
class ReminderCreate(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
title: str = Field(min_length=1, max_length=255)
|
|
description: Optional[str] = Field(None, max_length=5000)
|
|
remind_at: Optional[datetime] = None
|
|
is_active: bool = True
|
|
recurrence_rule: Optional[Literal['daily', 'weekly', 'monthly']] = None
|
|
|
|
|
|
class ReminderUpdate(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
title: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
description: Optional[str] = Field(None, max_length=5000)
|
|
remind_at: Optional[datetime] = None
|
|
is_active: Optional[bool] = None
|
|
is_dismissed: Optional[bool] = None
|
|
recurrence_rule: Optional[Literal['daily', 'weekly', 'monthly']] = None
|
|
|
|
|
|
class ReminderSnooze(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
minutes: Literal[5, 10, 15]
|
|
client_now: Optional[datetime] = None
|
|
|
|
|
|
class ReminderResponse(BaseModel):
|
|
id: int
|
|
title: str
|
|
description: Optional[str]
|
|
remind_at: Optional[datetime]
|
|
is_active: bool
|
|
is_dismissed: bool
|
|
snoozed_until: Optional[datetime] = None
|
|
recurrence_rule: Optional[str]
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|