mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
feat: 用户名验证支持点号,统一错误消息,完善前端验证
- 后端正则改为 ^[a-zA-Z0-9_.\-]+$ 支持点号 - 统一错误消息使用"连字符" - 前端 UserFormDialog 和 RegisterDialog 添加实时验证 - 输入框显示格式提示和错误信息
This commit is contained in:
@@ -314,8 +314,8 @@ class UpdateUserRequest(BaseModel):
|
||||
if v is None:
|
||||
return v
|
||||
|
||||
if not re.match(r"^[a-zA-Z0-9_-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线和连字符")
|
||||
if not re.match(r"^[a-zA-Z0-9_.\-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线、连字符和点号")
|
||||
|
||||
return v
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ class RegisterRequest(BaseModel):
|
||||
v = v.strip()
|
||||
if not v:
|
||||
raise ValueError("用户名不能为空")
|
||||
if not re.match(r"^[a-zA-Z0-9_-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线和短横线")
|
||||
if not re.match(r"^[a-zA-Z0-9_.\-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线、连字符和点号")
|
||||
return v
|
||||
|
||||
@classmethod
|
||||
@@ -279,8 +279,8 @@ class CreateUserRequest(BaseModel):
|
||||
v = v.strip()
|
||||
if not v:
|
||||
raise ValueError("用户名不能为空")
|
||||
if not re.match(r"^[a-zA-Z0-9_-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线和短横线")
|
||||
if not re.match(r"^[a-zA-Z0-9_.\-]+$", v):
|
||||
raise ValueError("用户名只能包含字母、数字、下划线、连字符和点号")
|
||||
return v
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user