28 行
688 B
Python
28 行
688 B
Python
from __future__ import annotations
|
|
from pydantic import BaseModel, field_validator
|
|
|
|
|
|
class PricingItemSchema(BaseModel):
|
|
product_name: str
|
|
product_slug: str | None = None
|
|
price_from: str | None = None
|
|
price_unit: str | None = None
|
|
price_label: str | None = None
|
|
description: str | None = None
|
|
features: list[str] = []
|
|
notes: list[str] = []
|
|
is_visible: bool = True
|
|
|
|
@field_validator('features', 'notes', mode='before')
|
|
@classmethod
|
|
def coerce_none_to_list(cls, v):
|
|
return v if v is not None else []
|
|
|
|
|
|
class PricingItemResponse(PricingItemSchema):
|
|
id: int
|
|
sort_order: int = 0
|
|
|
|
class Config:
|
|
from_attributes = True
|