verify

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package verify data verification

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoverifyValueSet no verification value set
	ErrNoverifyValueSet = errors.New("未设置验证值")
)

Functions

func Batch

func Batch(elements ...*ValidEle) error

Batch assign multiple filtered results to the specified object

func Var

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
}

Engine valid engine

func Int

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

Int use int new valid

func New

func New() Engine

New new valid

func Text

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

Text use int new valid

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) CheckPassword

func (v Engine) CheckPassword(password string, customError ...string) Engine

CheckPassword check encrypt password

func (Engine) Customize

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

Customize customize valid

func (Engine) Default

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

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

func (Engine) EncryptPassword

func (v Engine) EncryptPassword(cost ...int) Engine

EncryptPassword encrypt the password

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) 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 boolean value

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 is number

func (Engine) IsURL

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

IsURL 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

MaxFloat maximum floating point value

func (Engine) MaxInt

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

MaxInt 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

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

Replace replace text

func (Engine) ReplaceAll

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

ReplaceAll replace all text

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 verify does not take effect by default

func (Engine) Separator

func (v Engine) Separator(sep string) Engine

Separator specify the separator of the slice type

func (Engine) SetAlias

func (v Engine) SetAlias(name string) Engine

SetAlias set alias

func (Engine) Silent

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

type ValidEle

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

ValidEle ValidEle

func BatchVar

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

BatchVar assign the filtered result to the specified variable

Jump to

Keyboard shortcuts

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