Documentation ¶
Index ¶
- func Bind(req *protocol.Request, obj interface{}, pathParams param.Params) error
- func BindAndValidate(req *protocol.Request, obj interface{}, pathParams param.Params) error
- func MustRegTypeUnmarshal(t reflect.Type, fn func(v string, emptyAsZero bool) (reflect.Value, error))
- func MustRegValidateFunc(funcName string, fn func(args ...interface{}) error, force ...bool)
- func SetErrorFactory(bindErrFactory, validatingErrFactory func(failField, msg string) error)
- func SetLooseZeroMode(enable bool)
- func UseGJSONUnmarshaler()
- func UseStdJSONUnmarshaler()
- func UseThirdPartyJSONUnmarshaler(unmarshaler func(data []byte, v interface{}) error)
- func Validate(obj interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindAndValidate ¶
BindAndValidate binds data from *protocol.Request to obj and validates them if needed. NOTE:
obj should be a pointer.
func MustRegTypeUnmarshal ¶
func MustRegTypeUnmarshal(t reflect.Type, fn func(v string, emptyAsZero bool) (reflect.Value, error))
MustRegTypeUnmarshal registers unmarshal function of type. NOTE:
It will panic if exist error. MustRegTypeUnmarshal will remain in effect once it has been called.
func MustRegValidateFunc ¶
MustRegValidateFunc registers validator function expression. NOTE:
If force=true, allow to cover the existed same funcName. MustRegValidateFunc will remain in effect once it has been called.
func SetErrorFactory ¶
SetErrorFactory customizes the factory of validation error. NOTE:
If errFactory==nil, the default is used. SetErrorFactory will remain in effect once it has been called.
func SetLooseZeroMode ¶
func SetLooseZeroMode(enable bool)
SetLooseZeroMode if set to true, the empty string request parameter is bound to the zero value of parameter. NOTE:
The default is false. Suitable for these parameter types: query/header/cookie/form .
func UseGJSONUnmarshaler ¶
func UseGJSONUnmarshaler()
UseGJSONUnmarshaler uses github.com/bytedance/go-tagexpr/v2/binding/gjson as json library NOTE:
UseGJSONUnmarshaler will remain in effect once it has been called.
func UseStdJSONUnmarshaler ¶
func UseStdJSONUnmarshaler()
UseStdJSONUnmarshaler uses encoding/json as json library NOTE:
The current version uses encoding/json by default. UseStdJSONUnmarshaler will remain in effect once it has been called.
func UseThirdPartyJSONUnmarshaler ¶
UseThirdPartyJSONUnmarshaler uses third-party json library for binding NOTE:
UseThirdPartyJSONUnmarshaler will remain in effect once it has been called.
Types ¶
This section is empty.