validators

package
v0.0.0-...-6562851 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IpAddrVf = func() (tag string, fn validator.Func) {
	return "asd", func(fl validator.FieldLevel) bool {
		date, ok := fl.Field().Interface().(time.Time)
		if ok {
			today := time.Now()
			if today.After(date) {
				return false
			}
		}
		return true
	}
}

Functions

func Init

func Init(locale string)

Init 验证器初始化

func InterceptError

func InterceptError(er error) (ok bool, errors string)

InterceptError 拦截自定义Error

func RemoveTopStruct

func RemoveTopStruct(fields map[string]string) map[string]string

RemoveTopStruct 移除多余的标签

Types

type JsonValidator

type JsonValidator struct {
	Validation  []Validation
	Translation []Translation
}

func (*JsonValidator) LoadTranslation

func (jv *JsonValidator) LoadTranslation(translations ...Translation) *JsonValidator

func (*JsonValidator) LoadValidation

func (jv *JsonValidator) LoadValidation(validations ...Validation) *JsonValidator

type Translation

type Translation func() (string, validator.RegisterTranslationsFunc, validator.TranslationFunc)

type Validation

type Validation func() (string, validator.Func)

Jump to

Keyboard shortcuts

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