binding

package
v0.0.0-...-e51fe83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(req *protocol.Request, obj interface{}, pathParams param.Params) error

Bind binds data from *protocol.Request to obj. NOTE:

obj should be a pointer.

func BindAndValidate

func BindAndValidate(req *protocol.Request, obj interface{}, pathParams param.Params) error

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

func MustRegValidateFunc(funcName string, fn func(args ...interface{}) error, force ...bool)

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

func SetErrorFactory(bindErrFactory, validatingErrFactory func(failField, msg string) error)

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

func UseThirdPartyJSONUnmarshaler(unmarshaler func(data []byte, v interface{}) error)

UseThirdPartyJSONUnmarshaler uses third-party json library for binding NOTE:

UseThirdPartyJSONUnmarshaler will remain in effect once it has been called.

func Validate

func Validate(obj interface{}) error

Validate validates obj with "vd" tag NOTE:

obj should be a pointer.
Validate should be called after Bind.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL