Version: v0.1.0 Latest Latest

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

Go to latest
Published: Jun 9, 2021 License: MIT Imports: 5 Imported by: 0




View Source
const (
	IgnoreFields = "-"


View Source
var (
	EMAIL_REG = regexp.MustCompile(emailPattern)
	URL_REG   = regexp.MustCompile(emailPattern)


func Capitalize added in v0.0.2

func Capitalize(str string) string

func Validate

func Validate(i interface{}) error

Validate field validate if validate ,return "", true if not, return the first invalid field name, and false


type Tag

type Tag struct {
	//	Tag    string
	Eq  string `method:"Equals"`
	Gt  string `method:"GreaterThan"`
	Gte string `method:"GreaterThanOrEqual"`
	Lt  string `method:"LessThan"`
	Lte string `method:"LessThanOrEqual"`
	Ne  string `method:"NotEqual"`

	Min    int `method:"MaxValidate"`
	Max    int `method:"MinValidate"`
	Length int `method:"LengthValidate"`

	Email   bool `method:"EmailValidate"`
	Url     bool `method:"UrlValidate"`
	NoSpace bool `method:"NoSpaceValidate"`

func (Tag) EmailValidate

func (n Tag) EmailValidate(v reflect.Value) bool

func (Tag) Equals

func (n Tag) Equals(v reflect.Value) (bool, string)

func (Tag) GreaterThan

func (n Tag) GreaterThan(v reflect.Value) (bool, string)

func (Tag) GreaterThanOrEqual

func (n Tag) GreaterThanOrEqual(v reflect.Value) (bool, string)

func (Tag) LengthValidate

func (n Tag) LengthValidate(v reflect.Value) (bool, string)

func (Tag) LessThan

func (n Tag) LessThan(v reflect.Value) (bool, string)

func (Tag) LessThanOrEqual

func (n Tag) LessThanOrEqual(v reflect.Value) (bool, string)

func (Tag) MaxValidate

func (n Tag) MaxValidate(v reflect.Value) (bool, string)

func (Tag) MinValidate

func (n Tag) MinValidate(v reflect.Value) (bool, string)

func (Tag) NoSpaceValidate

func (n Tag) NoSpaceValidate(v reflect.Value) (bool, string)

func (Tag) NotEqual

func (n Tag) NotEqual(v reflect.Value) (bool, string)

func (Tag) UrlValidate

func (n Tag) UrlValidate(v reflect.Value) (bool, string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL