This commit is contained in:
fengchuanhn@gmail.com
2026-05-23 10:33:29 +08:00
parent c5f12421af
commit a27905a2fe
3 changed files with 16 additions and 4 deletions

View File

@@ -7,8 +7,17 @@ CardKeyType = Literal["时长", "点数"]
class CardKeyActivateRequest(BaseModel):
username: str = Field(min_length=1, max_length=64)
serial_number: str = Field(min_length=1, max_length=64)
@field_validator("username")
@classmethod
def normalize_username(cls, value: str) -> str:
stripped = value.strip()
if not stripped:
raise ValueError("请输入用户名")
return stripped
@field_validator("serial_number")
@classmethod
def normalize_serial(cls, value: str) -> str: