-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix:Add required check for customed type binding #1058
base: develop
Are you sure you want to change the base?
Conversation
…cated with customed type is invalid in previous version. This pr solves this problem by adding required check for customed type binding. What's more, I find that custom type should not only use json tag, because it's useless. This should be pointed out in the document. \n Closes cloudwego#1007
感谢 pr,确实应该做一次 required 校验。请先签一下 CLA |
CLA应该已经签了,我看测试golint没过,是不是要规范一下代码 |
…hertz-develop into customBindingRequired-fix-branch
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1058 +/- ##
===========================================
+ Coverage 82.52% 82.54% +0.02%
===========================================
Files 98 98
Lines 10025 10026 +1
===========================================
+ Hits 8273 8276 +3
+ Misses 1255 1254 -1
+ Partials 497 496 -1 ☔ View full report in Codecov by Sentry. |
break | ||
} | ||
if tagInfo.Required { | ||
err = fmt.Errorf("'%s' field is a 'required' parameter, but the request does not have this parameter", d.fieldName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do not return the err here directly?
What type of PR is this?
Check the PR title.
(Optional) Translate the PR title into Chinese.
为自定义类型添加required检查
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:Required tag assocated with customed type is invalid in previous version. This pr solves this problem by adding required check for customed type binding. What's more, I find that custom type should not only use json tag, because it's useless. This should be pointed out in the document.
zh(optional):与自定义类型关联的必需标记在早期版本中无效。此pr通过为自定义类型绑定添加必需的检查来解决此问题。更重要的是,我发现自定义类型不应该只使用json标记,因为它是无用的。这一点应在文档中指出。
(Optional) Which issue(s) this PR fixes:
Fixes #1007