35 lines
935 B
Python
35 lines
935 B
Python
|
|
"""Currency schemas — create, update, read, list."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class CurrencyCreate(BaseModel):
|
||
|
|
code: str = Field(..., min_length=3, max_length=3, description="ISO 4217 code, e.g. EUR")
|
||
|
|
name: str = Field(..., min_length=1, max_length=50)
|
||
|
|
symbol: str = Field(..., min_length=1, max_length=5)
|
||
|
|
is_default: bool = False
|
||
|
|
|
||
|
|
|
||
|
|
class CurrencyUpdate(BaseModel):
|
||
|
|
code: str | None = Field(None, min_length=3, max_length=3)
|
||
|
|
name: str | None = Field(None, min_length=1, max_length=50)
|
||
|
|
symbol: str | None = Field(None, min_length=1, max_length=5)
|
||
|
|
is_default: bool | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class CurrencyResponse(BaseModel):
|
||
|
|
id: str
|
||
|
|
code: str
|
||
|
|
name: str
|
||
|
|
symbol: str
|
||
|
|
is_default: bool
|
||
|
|
created_at: str | None = None
|
||
|
|
updated_at: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class CurrencyListResponse(BaseModel):
|
||
|
|
items: list[CurrencyResponse]
|
||
|
|
total: int
|