Skip to content
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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

iksars
Copy link

@iksars iksars commented Feb 1, 2024

What type of PR is this?

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(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

…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
@iksars iksars requested review from a team as code owners February 1, 2024 10:39
@CLAassistant
Copy link

CLAassistant commented Feb 1, 2024

CLA assistant check
All committers have signed the CLA.

@FGYFFFF
Copy link
Contributor

FGYFFFF commented Feb 18, 2024

感谢 pr,确实应该做一次 required 校验。请先签一下 CLA

@iksars
Copy link
Author

iksars commented Feb 18, 2024

感谢 pr,确实应该做一次 required 校验。请先签一下 CLA

CLA应该已经签了,我看测试golint没过,是不是要规范一下代码

Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.54%. Comparing base (532011f) to head (253b97a).
Report is 5 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

break
}
if tagInfo.Required {
err = fmt.Errorf("'%s' field is a 'required' parameter, but the request does not have this parameter", d.fieldName)
Copy link
Member

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?

@iksars iksars requested a review from welkeyever March 7, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

A collison between hertz customed type binding and 'required' tag check
4 participants