-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodels.py
More file actions
30 lines (23 loc) · 785 Bytes
/
Copy pathmodels.py
File metadata and controls
30 lines (23 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Pydantic models for request/response validation
"""
from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
class ItemCreate(BaseModel):
"""Model for creating an item"""
name: str = Field(..., min_length=1, max_length=100)
description: Optional[str] = Field(None, max_length=500)
value: float = Field(default=0.0, ge=0)
class ItemUpdate(BaseModel):
"""Model for updating an item"""
name: Optional[str] = Field(None, min_length=1, max_length=100)
description: Optional[str] = Field(None, max_length=500)
value: Optional[float] = Field(None, ge=0)
class Item(BaseModel):
"""Model for item response"""
id: int
name: str
description: Optional[str]
value: float
created_at: datetime