格式化验证失败的错误信息, 默认tag=err, 支持重置默认tag

This commit is contained in:
2025-02-07 18:01:05 +08:00
parent a338713c77
commit 7c67160c65
4 changed files with 84 additions and 1 deletions

View File

@ -31,6 +31,8 @@ func RequestHandler(uriCfg UriConfig) gin.HandlerFunc {
formData := reflect.New(uriCfg.FormDataType).Interface()
// 表单解析
if err = request.Form.Parse(ctx, formData); nil != err {
// 格式化验证错误的信息
err = GetValidateErr(formData, err)
e = exception.NewFromError(400, err)
response.SendWithException(ctx, e, nil)
return