zvalid

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoValidationValueSet = errors.New("未设置验证值")
)

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New() *Engine

func Text

func Text(value string, name ...string) *Engine

func (*Engine) Bool

func (v *Engine) Bool() (bool, error)

Bool to bool

func (*Engine) CamelCaseToSnakeCase

func (v *Engine) CamelCaseToSnakeCase(str string, delimiter ...string) *Engine

CamelCaseToSnakeCase camelCase To SnakeCase helloWorld/HelloWorld => hello_world

func (*Engine) Customize

func (v *Engine) Customize(fn func(rawValue string, err error) (newValue string, newErr error)) *Engine

Customize customize valid

func (*Engine) EnumFloat64

func (v *Engine) EnumFloat64(f []float64, customError ...string) *Engine

EnumFloat64 allow only values ​​in []float64

func (*Engine) EnumInt

func (v *Engine) EnumInt(i []int, customError ...string) *Engine

EnumInt allow only values ​​in []int

func (*Engine) EnumString

func (v *Engine) EnumString(slice []string, customError ...string) *Engine

EnumString allow only values ​​in []string

func (*Engine) Error

func (v *Engine) Error() (err error)

Error or whether the verification fails

func (*Engine) Float64

func (v *Engine) Float64() (float64, error)

Float64 convert to float64

func (*Engine) HasLetter

func (v *Engine) HasLetter(customError ...string) *Engine

HasLetter must contain letters not case sensitive

func (*Engine) HasLower

func (v *Engine) HasLower(customError ...string) *Engine

HasLower must contain lowercase letters

func (*Engine) HasNumber

func (v *Engine) HasNumber(customError ...string) *Engine

HasNumber must contain numbers

func (*Engine) HasPrefix

func (v *Engine) HasPrefix(sub string, customError ...string) *Engine

HasPrefix must contain the specified prefix string

func (*Engine) HasString

func (v *Engine) HasString(sub string, customError ...string) *Engine

HasString must contain a specific string

func (*Engine) HasSuffix

func (v *Engine) HasSuffix(sub string, customError ...string) *Engine

HasSuffix contains the specified suffix string

func (*Engine) HasSymbol

func (v *Engine) HasSymbol(customError ...string) *Engine

HasSymbol must contain symbols

func (*Engine) HasUpper

func (v *Engine) HasUpper(customError ...string) *Engine

HasUpper must contain uppercase letters

func (*Engine) Int

func (v *Engine) Int() (int, error)

Int convert to int

func (*Engine) IsBool

func (v *Engine) IsBool(customError ...string) *Engine

IsBool booleanValue

func (*Engine) IsChinese

func (v *Engine) IsChinese(customError ...string) *Engine

IsChinese chinese character

func (*Engine) IsChineseIDNumber

func (v *Engine) IsChineseIDNumber(customError ...string) *Engine

IsChineseIDNumber mainland china id number

func (*Engine) IsIP

func (v *Engine) IsIP(customError ...string) *Engine

IsIP ipv4 v6 address

func (*Engine) IsJSON

func (v *Engine) IsJSON(customError ...string) *Engine

IsJSON valid json format

func (*Engine) IsLetter

func (v *Engine) IsLetter(customError ...string) *Engine

IsLetter uppercase and lowercase letters

func (*Engine) IsLetterOrDigit

func (v *Engine) IsLetterOrDigit(customError ...string) *Engine

IsLetterOrDigit letters or numbers

func (*Engine) IsLower

func (v *Engine) IsLower(customError ...string) *Engine

IsLower lowerCase letters

func (*Engine) IsLowerOrDigit

func (v *Engine) IsLowerOrDigit(customError ...string) *Engine

IsLowerOrDigit lowercase letters or numbers

func (*Engine) IsMail

func (v *Engine) IsMail(customError ...string) *Engine

IsMail email address

func (*Engine) IsMobile

func (v *Engine) IsMobile(customError ...string) *Engine

IsMobile chinese mobile

func (*Engine) IsNumber

func (v *Engine) IsNumber(customError ...string) *Engine

IsNumber number

func (*Engine) IsURL

func (v *Engine) IsURL(customError ...string) *Engine

isURL links

func (*Engine) IsUpper

func (v *Engine) IsUpper(customError ...string) *Engine

IsUpper uppercase letter

func (*Engine) IsUpperOrDigit

func (v *Engine) IsUpperOrDigit(customError ...string) *Engine

IsUpperOrDigit uppercase letters or numbers

func (*Engine) MaxFloat

func (v *Engine) MaxFloat(max float64, customError ...string) *Engine

MinFloat maximum floating point value

func (*Engine) MaxInt

func (v *Engine) MaxInt(max int, customError ...string) *Engine

MinInt maximum integer value

func (*Engine) MaxLength

func (v *Engine) MaxLength(max int, customError ...string) *Engine

MaxLength the maximum length

func (*Engine) MaxUTF8Length

func (v *Engine) MaxUTF8Length(max int, customError ...string) *Engine

MaxUTF8Length utf8 encoding maximum length

func (*Engine) MinFloat

func (v *Engine) MinFloat(min float64, customError ...string) *Engine

MinFloat minimum floating point value

func (*Engine) MinInt

func (v *Engine) MinInt(min int, customError ...string) *Engine

MinInt minimum integer value

func (*Engine) MinLength

func (v *Engine) MinLength(min int, customError ...string) *Engine

MinLength minimum length

func (*Engine) MinUTF8Length

func (v *Engine) MinUTF8Length(min int, customError ...string) *Engine

MinUTF8Length utf8 encoding minimum length

func (*Engine) Ok

func (v *Engine) Ok() bool

Ok not err

func (*Engine) Password

func (v *Engine) Password(customError ...string) *Engine

Password Universal password (any visible character, length between 6 ~ 20)

func (*Engine) RemoveSpace

func (v *Engine) RemoveSpace() *Engine

RemoveSpace remove all spaces

func (*Engine) ReplaceAll

func (v *Engine) ReplaceAll(old, new string) *Engine

ReplaceAll replace all

func (*Engine) Required

func (v *Engine) Required(customError ...string) *Engine

Required Must have a value (zero values ​​other than "" are allowed). If this rule is not used, when the parameter value is "", data validation does not take effect by default

func (*Engine) Result

func (v *Engine) Result() (string, error)

Result get the final value, or an notEmpty string if an error occurs

func (*Engine) SnakeCaseToCamelCase

func (v *Engine) SnakeCaseToCamelCase(ucfirst bool, delimiter ...string) *Engine

SnakeCaseToCamelCase snakeCase To CamelCase: hello_world => helloWorld

func (*Engine) Split

func (v *Engine) Split(sep string) ([]string, error)

Split converted to [] string

func (*Engine) String

func (v *Engine) String() (string, error)

String to string

func (*Engine) StrongPassword

func (v *Engine) StrongPassword(customError ...string) *Engine

StrongPassword Strong equal strength password (length is 6 ~ 20, must include uppercase and lowercase letters, numbers and special characters)

func (*Engine) Trim

func (v *Engine) Trim() *Engine

Trim remove leading and trailing spaces

func (*Engine) Value

func (v *Engine) Value() (value string)

Value get the final value

func (*Engine) Verifi

func (v *Engine) Verifi(value string, name ...string) *Engine

Verifi validate specified data

func (*Engine) XssClean

func (v *Engine) XssClean() *Engine

XssClean clean html tag

Jump to

Keyboard shortcuts

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