validator

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transtate

func Transtate() ut.Translator

开放一个方法,供全局访问翻译器

func Validate

func Validate() *validator.Validate

开放一个方法,供全局访问验证器

func ValidateStruct

func ValidateStruct(s interface{}) (err error)

开放一个通用方法,打印日志,并返回校验错误,貌似这个里封装一下,把翻译过来的错误放到输出里更好

Types

type ValidatorStarter

type ValidatorStarter struct {
	infra.BaseStarter
}

func (*ValidatorStarter) Init

func (v *ValidatorStarter) Init(ctx infra.StarterContext)

因为验证器的初始化优先级不是最高的,只需要放到web初始化接收请求之前即可,所以用Init方法来构造

Jump to

Keyboard shortcuts

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