validator

package
v0.0.0-...-883d24b Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalValidatorMapping = make(map[i18n.Language]*MyValidator, 0)

GlobalValidatorMapping is a mapping from validator to translator used

Functions

func NotBlank

func NotBlank(fl validator.FieldLevel) (res bool)

func Sanitizer

func Sanitizer(fl validator.FieldLevel) (res bool)

Types

type Checker

type Checker interface {
	Check() (errField []*FormErrorField, err error)
}

Checker .

type FormErrorField

type FormErrorField struct {
	ErrorField string `json:"error_field"`
	ErrorMsg   string `json:"error_msg"`
}

FormErrorField indicates the current form error content. which field is error and error message.

type MyValidator

type MyValidator struct {
	Validate *validator.Validate
	Tran     ut.Translator
	Lang     i18n.Language
}

MyValidator my validator

func GetValidatorByLang

func GetValidatorByLang(lang i18n.Language) *MyValidator

func (*MyValidator) Check

func (m *MyValidator) Check(value interface{}) (errFields []*FormErrorField, err error)

Check /

type TranslatorLocal

type TranslatorLocal struct {
	La           i18n.Language
	Lo           locales.Translator
	RegisterFunc func(v *validator.Validate, trans ut.Translator) (err error)
}

Jump to

Keyboard shortcuts

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