zvalid

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 11 Imported by: 4

Documentation

Overview

Package zvalid data verification

Index

Constants

This section is empty.

Variables

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

Functions

func Batch added in v0.0.21

func Batch(elements ...*ele) error

Batch assign multiple filtered results to the specified object

func BatchVar added in v0.0.21

func BatchVar(target interface{}, source Engine) *ele

BatchVar assign the filtered result to the specified variable

func Var added in v0.0.21

func Var(target interface{}, source Engine, name ...string) error

Var assign the filtered result to the specified variable

Types

type Engine

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

func Int added in v0.1.28

func Int(value int, name ...string) Engine

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(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) Default added in v0.0.21

func (v Engine) Default(value interface{}) Engine

Default if a filtering error occurs, the default value is assigned to the variable

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() 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) HasNumber2 added in v0.1.31

func (v Engine) HasNumber2(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) Replace added in v0.1.28

func (v Engine) Replace(old, new string, n int) Engine

ReplaceAll replace

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() Engine

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

func (Engine) Separator added in v0.0.21

func (v Engine) Separator(sep string) Engine

Separator specify the separator of the slice type

func (Engine) Silent added in v0.0.21

func (v Engine) Silent() Engine

Silent an error occurred during filtering, no error is returned

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