🎨 抽卡记录导入验证数据

This commit is contained in:
xtaodada 2022-10-09 12:49:41 +08:00
parent b8c30768a6
commit 2da69d3d5e
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 4 additions and 3 deletions

View File

@ -100,7 +100,7 @@ roles = {
10000073: ['纳西妲', 'Nahida', 'nahida', '草王', '草神', '小吉祥草王', '草萝莉', '纳西坦'], 10000073: ['纳西妲', 'Nahida', 'nahida', '草王', '草神', '小吉祥草王', '草萝莉', '纳西坦'],
10000074: ['莱依拉', 'Layla', 'layla', '拉一拉'], 10000074: ['莱依拉', 'Layla', 'layla', '拉一拉'],
} }
not_real_roles = ["纳西妲", "莱依拉"] not_real_roles = [10000073, 10000074]
weapons = { weapons = {
"磐岩结绿": ["绿箭", "绿剑"], "磐岩结绿": ["绿箭", "绿剑"],
"斫峰之刃": ["斫峰", "盾剑"], "斫峰之刃": ["斫峰", "盾剑"],

View File

@ -56,7 +56,8 @@ class GachaItem(BaseModel):
@validator("name") @validator("name")
def name_validator(cls, v): def name_validator(cls, v):
if (roleToId(v) or weaponToId(v)) and v not in not_real_roles: if item_id := (roleToId(v) or weaponToId(v)):
if item_id not in not_real_roles:
return v return v
raise ValueError("Invalid name") raise ValueError("Invalid name")