From 82a5a50c4b303c0b0fd339d2677d93015bde8dfe Mon Sep 17 00:00:00 2001 From: ITQ Date: Wed, 29 Jan 2025 19:43:39 +0300 Subject: [PATCH] fix: postchecks fix, added ability to filter by country with , separator --- solution/api/v1/business/schemas.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/solution/api/v1/business/schemas.py b/solution/api/v1/business/schemas.py index ad40d52..c4e9449 100644 --- a/solution/api/v1/business/schemas.py +++ b/solution/api/v1/business/schemas.py @@ -87,7 +87,14 @@ class PromocodeListFilters(Schema): 0, ge=0, description="Offset must be greater than or equal to 0" ) sort_by: Literal["active_from", "active_until", None] = None - country__in: list[CountryAlpha2] = Field(None, alias="country") + country__in: list[CountryAlpha2] | str = Field(None, alias="country") + + @field_validator("country__in", mode="before") + def validate_counrty__in(cls, value: Any) -> Any: + if isinstance(value, list) and len(value) == 1: + value = value[0].split(",") + + return value class PromocodeTargetViewOut(Schema):