validators

package
v0.0.0-...-0b4b916 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PasswordPattern = regexp.MustCompile(`^[a-zA-Z0-9_]{6,20}$`)
)
View Source
var (
	UsernamePattern = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_]{5,19}$`)
)

Functions

func Build

func Build()

func CheckErrors

func CheckErrors(errors error)

func NotBlank

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

func PasswordValid

func PasswordValid(fl validator.FieldLevel) bool

func Sanitizer

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

func UsernameValid

func UsernameValid(fl validator.FieldLevel) 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
}

MyValidator my validator

var GlobalValidator *MyValidator

func (*MyValidator) Check

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

Check /

Jump to

Keyboard shortcuts

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