Documentation
¶
Overview ¶
Package validator implements some validate function for string.
Index ¶
- func ContainChinese(s string) bool
- func ContainLetter(str string) bool
- func ContainLower(str string) bool
- func ContainUpper(str string) bool
- func IsAllLower(str string) bool
- func IsAllUpper(str string) bool
- func IsAlpha(str string) bool
- func IsBase64(base64 string) bool
- func IsChineseIdNum(id string) bool
- func IsChineseMobile(mobileNum string) bool
- func IsChinesePhone(phone string) bool
- func IsCreditCard(creditCart string) bool
- func IsDns(dns string) bool
- func IsEmail(email string) bool
- func IsEmptyString(str string) bool
- func IsFloatStr(str string) bool
- func IsGBK(data []byte) bool
- func IsIntStr(str string) bool
- func IsIp(ipstr string) bool
- func IsIpV4(ipstr string) bool
- func IsIpV6(ipstr string) bool
- func IsJSON(str string) bool
- func IsNumberStr(s string) bool
- func IsPort(str string) bool
- func IsRegexMatch(str, regex string) bool
- func IsStrongPassword(password string, length int) bool
- func IsUrl(str string) bool
- func IsWeakPassword(password string) bool
- func IsZeroValue(value any) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainChinese ¶
ContainChinese check if the string contain mandarin chinese.
func ContainLetter ¶
ContainLetter check if the string contain at least one letter
func ContainLower ¶
ContainLower check if the string contain at least one lower case letter A-Z
func ContainUpper ¶
ContainUpper check if the string contain at least one upper case letter A-Z
func IsAllLower ¶
IsAllLower check if the string is all lower case letters a-z
func IsAllUpper ¶
IsAllUpper check if the string is all upper case letters A-Z
func IsChineseIdNum ¶
IsChineseIdNum check if the string is chinese id number.
func IsChineseMobile ¶
IsChineseMobile check if the string is chinese mobile number.
func IsChinesePhone ¶
IsChinesePhone check if the string is chinese phone number. Valid chinese phone is xxx-xxxxxxxx or xxxx-xxxxxxx
func IsCreditCard ¶
IsCreditCard check if the string is credit card.
func IsEmptyString ¶
IsEmptyString check if the string is empty.
func IsFloatStr ¶
IsFloatStr check if the string can convert to a float.
func IsGBK ¶ added in v2.1.12
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 IsNumberStr ¶
IsNumberStr check if the string can convert to a number.
func IsRegexMatch ¶
IsRegexMatch check if the string match the regexp
func IsStrongPassword ¶
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 IsWeakPassword ¶
IsWeakPassword check if the string is weak password Weak password: only letter or only number or letter + number
func IsZeroValue ¶ added in v2.1.6
IsZeroValue checks if value is a zero value
Types ¶
This section is empty.