From 5053d975fb390dffa65f9bea5b0aa8c51763f1b7 Mon Sep 17 00:00:00 2001 From: seria Date: Thu, 28 Nov 2024 08:06:23 +0800 Subject: [PATCH] fix: Fix ValidationError in WeaponLeaderboard.filters when passed in value is null --- akasha/models/category.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/akasha/models/category.py b/akasha/models/category.py index af69bde..f66eb64 100644 --- a/akasha/models/category.py +++ b/akasha/models/category.py @@ -56,6 +56,11 @@ class WeaponLeaderboard(BaseModel): def __parse_teammates(cls, v: list[dict[str, Any]]) -> list[LeaderboardTeammate]: return [LeaderboardTeammate(**teammate) for teammate in v if "name" in teammate] + @field_validator("filters", mode="before") + @classmethod + def __parse_filters(cls, v: list[dict[str, Any]] | None) -> list[WeaponLeaderboardFilter]: + return [WeaponLeaderboardFilter(**filter_) for filter_ in v] if v else [] + class LeaderboardCategory(BaseModel): id: str = Field(alias="_id")