validator

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package validator implements some validate function for string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainChinese

func ContainChinese(s string) bool

ContainChinese check if the string contain mandarin chinese.

func ContainLetter added in v1.2.0

func ContainLetter(str string) bool

ContainLetter check if the string contain at least one letter

func ContainLower added in v1.2.0

func ContainLower(str string) bool

ContainLower check if the string contain at least one lower case letter A-Z

func ContainUpper added in v1.2.0

func ContainUpper(str string) bool

ContainUpper check if the string contain at least one upper case letter A-Z

func IsASCII added in v1.3.8

func IsASCII(str string) bool

IsASCII checks if string is all ASCII char.

func IsAllLower added in v1.2.0

func IsAllLower(str string) bool

IsAllLower check if the string is all lower case letters a-z

func IsAllUpper added in v1.2.0

func IsAllUpper(str string) bool

IsAllUpper check if the string is all upper case letters A-Z

func IsAlpha

func IsAlpha(str string) bool

IsAlpha checks if the string contains only letters (a-zA-Z)

func IsAmericanExpress added in v1.4.2

func IsAmericanExpress(v string) bool

IsAmericanExpress check if a give string is a valid american expression card nubmer or not.

func IsBase64

func IsBase64(base64 string) bool

IsBase64 check if the string is base64 string.

func IsBase64URL added in v1.4.2

func IsBase64URL(v string) bool

IsBase64URL check if a give string is a valid URL-safe Base64 encoded string.

func IsBin added in v1.4.2

func IsBin(v string) bool

IsBin check if a give string is a valid binary value or not.

func IsChinaUnionPay added in v1.4.2

func IsChinaUnionPay(v string) bool

IsChinaUnionPay check if a give string is a valid china union pay nubmer or not.

func IsChineseIdNum

func IsChineseIdNum(id string) bool

IsChineseIdNum check if the string is chinese id number.

func IsChineseMobile

func IsChineseMobile(mobileNum string) bool

IsChineseMobile check if the string is chinese mobile number.

func IsChinesePhone

func IsChinesePhone(phone string) bool

IsChinesePhone check if the string is chinese phone number. Valid chinese phone is xxx-xxxxxxxx or xxxx-xxxxxxx

func IsCreditCard

func IsCreditCard(creditCart string) bool

IsCreditCard check if the string is credit card.

func IsDns

func IsDns(dns string) bool

IsDns check if the string is dns.

func IsEmail

func IsEmail(email string) bool

IsEmail check if the string is a email address.

func IsEmptyString

func IsEmptyString(str string) bool

IsEmptyString check if the string is empty.

func IsFloat added in v1.3.8

func IsFloat(v interface{}) bool

IsFloat check if the value is float(float32, float34) or not.

func IsFloatStr

func IsFloatStr(str string) bool

IsFloatStr check if the string can convert to a float.

func IsGBK added in v1.3.5

func IsGBK(data []byte) bool

IsGBK check if data encoding is gbk Note: this function is implemented by whether double bytes fall within the encoding range of gbk, while each byte of utf-8 encoding format falls within the encoding range of gbk. Therefore, utf8.valid() should be called first to check whether it is not utf-8 encoding, and then call IsGBK() to check gbk encoding. like below *

data := []byte("你好")
if utf8.Valid(data) {
	fmt.Println("data encoding is utf-8")
}else if(IsGBK(data)) {
	fmt.Println("data encoding is GBK")
}
fmt.Println("data encoding is unknown")

*

func IsHex added in v1.4.2

func IsHex(v string) bool

IsHex check if a give string is a valid hexadecimal value or not.

func IsInt added in v1.3.8

func IsInt(v interface{}) bool

IsInt check if the value is integer(int, unit) or not.

func IsIntStr

func IsIntStr(str string) bool

IsIntStr check if the string can convert to a integer.

func IsIp

func IsIp(ipstr string) bool

IsIp check if the string is a ip address.

func IsIpV4

func IsIpV4(ipstr string) bool

IsIpV4 check if the string is a ipv4 address.

func IsIpV6

func IsIpV6(ipstr string) bool

IsIpV6 check if the string is a ipv6 address.

func IsJSON added in v1.2.0

func IsJSON(str string) bool

IsJSON checks if the string is valid JSON

func IsJWT added in v1.4.2

func IsJWT(v string) bool

IsJWT check if a give string is a valid JSON Web Token (JWT).

func IsMasterCard added in v1.4.2

func IsMasterCard(v string) bool

IsMasterCard check if a give string is a valid master card nubmer or not.

func IsNumber added in v1.3.8

func IsNumber(v interface{}) bool

IsNumberStr check if the value is number(integer, float) or not.

func IsNumberStr

func IsNumberStr(s string) bool

IsNumberStr check if the string can convert to a number.

func IsPort added in v1.2.0

func IsPort(str string) bool

IsPort check if the string is a valid net port.

func IsPrintable added in v1.3.8

func IsPrintable(str string) bool

IsPrintable checks if string is all printable chars.

func IsRegexMatch

func IsRegexMatch(str, regex string) bool

IsRegexMatch check if the string match the regexp

func IsStrongPassword

func IsStrongPassword(password string, length int) bool

IsStrongPassword check if the string is strong password, if len(password) is less than the length param, return false Strong password: alpha(lower+upper) + number + special chars(!@#$%^&*()?><)

func IsUnionPay added in v1.4.2

func IsUnionPay(v string) bool

IsUnionPay check if a give string is a valid union pay nubmer or not.

func IsUrl added in v1.2.2

func IsUrl(str string) bool

IsUrl check if the string is url.

func IsVisa added in v1.4.2

func IsVisa(v string) bool

IsVisa check if a give string is a valid visa card nubmer or not.

func IsWeakPassword

func IsWeakPassword(password string) bool

IsWeakPassword check if the string is weak password Weak password: only letter or only number or letter + number

func IsZeroValue added in v1.3.2

func IsZeroValue(value interface{}) bool

IsZeroValue checks if value is a zero value

Types

This section is empty.

Jump to

Keyboard shortcuts

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