Skip to content

Commit

Permalink
Fix validation error on ShiyuDefenseMonster
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Sep 21, 2024
1 parent aa3a00a commit a4e7c96
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion genshin/models/zzz/chronicle/challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ class ShiyuDefenseMonster(APIModel):

id: int
name: str
weakness: ZZZElementType = Aliased("weak_element_type")
weakness: typing.Union[ZZZElementType, int] = Aliased("weak_element_type")
level: int

@pydantic.validator("weakness", pre=True)
def __convert_weakness(cls, v: int) -> typing.Union[ZZZElementType, int]:
try:
return ZZZElementType(v)
except ValueError:
return v


class ShiyuDefenseNode(APIModel):
"""Shiyu Defense node model."""
Expand Down

0 comments on commit a4e7c96

Please sign in to comment.