Files
Nexus/docs/changelog/2026-06-08-settings-form-validate-zh-errors.md
T
Nexus Agent 632891e6e5 fix(settings): 表单校验与 422 中文错误信息
v-form 保存前 validate;validation_errors_zh 翻译 Pydantic msg;value 数字 coerce。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 14:52:59 +08:00

33 lines
1002 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 设置页表单校验与 API 422 中文校验
**日期**2026-06-08
## 变更摘要
1. 设置页「系统设置」包在 `v-form` 内,保存前 `validate()`,连接池范围 11000。
2. 全局 422`validation_errors_zh.py` 将 Pydantic 默认英文 `msg` 译为中文。
3. `SettingUpdatePayload.value` 增加 before 校验,数字自动转字符串(双保险)。
## 动机
- 保存设置不跑前端 rules,空值/超范围仍提交。
- 用户可见 `Input should be a valid string` 等英文校验。
## 涉及文件
- `frontend/src/pages/SettingsPage.vue`
- `server/utils/validation_errors_zh.py`(新)
- `server/main.py` — 422 handler
- `server/api/schemas.py` — SettingUpdatePayload
- `tests/test_validation_errors_zh.py`
## 迁移 / 重启
后端需重启/部署;前端构建部署。
## 验证
- 设置页空连接池点保存 → 前端提示,无请求
- `pytest tests/test_validation_errors_zh.py`
- PUT settings 传 `{value: 160}` → 200coerce