cloudwego / hertz

Go HTTP framework with high-performance and strong-extensibility for building micro-services.
https://www.cloudwego.io
Apache License 2.0
5.04k stars 491 forks source link

optimize: optimize the error message of the `required` constraint for binding #1119

Closed haoxins closed 2 months ago

haoxins commented 3 months ago

What type of PR is this?

optimize

Check the PR title.

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:

If we have the binding or params definition:


type Params struct {
    AccId string `query:"accountId,required"
}

The current error message will be:

"'AccId' field is a 'required' parameter, but the request does not have this parameter"

This will be confused for the API caller.

The error message will be

"'accountId' field is a 'required' parameter, but the request does not have this parameter"

with this change.

zh(optional):

(Optional) Which issue(s) this PR fixes:

(Optional) The PR that updates user documentation:

FGYFFFF commented 3 months ago

可以看看其他地方的 Required 校验是否也有类似的 case,可以一并修改

haoxins commented 3 months ago

可以看看其他地方的 Required 校验是否也有类似的 case,可以一并修改

done