fix: customized type decode for binding #965
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
fix
Check the PR title.
(Optional) Translate the PR title into Chinese.
修复自定义绑定函数带来的 time.Time 绑定不一致的行为
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en: Fix inconsistent behavior of time.Time bindings due to custom binding functions
zh(optional): 修复自定义绑定函数带来的 time.Time 绑定不一致的行为
之前的绑定行为是必须有对应的 tag 才会去执行,自定义校验函数,例如下方结构体,只有请求的 query 有 "A" 的时候才会去执行自定义绑定函数。
重构后,修改了这一行为,认为 "只要定义了自定义绑定函数就一定会执行,并且会将请求内容传给用户,让其自行取值",所以自带的 time.Time 的自定义方法会将用户 json 已经解析过的 time.Time 覆盖掉。
这块还是改回只有 tag 存在才执行自定义方法,避免出现其他覆盖的行为
(Optional) Which issue(s) this PR fixes:
#964
(Optional) The PR that updates user documentation: