Documentation ¶
Overview ¶
Package validator Date: 2023/7/11 18:34 Author: Amu Description:
Index ¶
- func ContainChinese(s string) bool
- func ContainLetter(str string) bool
- func ContainLower(str string) bool
- func ContainNumber(input string) bool
- func ContainUpper(str string) bool
- func IsASCII(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 IsFloat(v any) bool
- func IsFloatStr(str string) bool
- func IsGBK(data []byte) bool
- func IsInt(v any) 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 IsNumber(v any) bool
- func IsNumberStr(s string) bool
- func IsPort(str string) bool
- func IsPrintable(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. Play: https://go.dev/play/p/7DpU0uElYeM
func ContainLetter ¶
ContainLetter check if the string contain at least one letter. Play: https://go.dev/play/p/lqFD04Yyewp
func ContainLower ¶
ContainLower check if the string contain at least one lower case letter a-z. Play: https://go.dev/play/p/Srqi1ItvnAA
func ContainNumber ¶
ContainLetter check if the string contain at least one number.
func ContainUpper ¶
ContainUpper check if the string contain at least one upper case letter A-Z. Play: https://go.dev/play/p/CmWeBEk27-z
func IsASCII ¶
IsASCII checks if string is all ASCII char. Play: https://go.dev/play/p/hfQNPLX0jNa
func IsAllLower ¶
IsAllLower check if the string is all lower case letters a-z. Play: https://go.dev/play/p/GjqCnOfV6cM
func IsAllUpper ¶
IsAllUpper check if the string is all upper case letters A-Z. Play: https://go.dev/play/p/ZHctgeK1n4Z
func IsAlpha ¶
IsAlpha checks if the string contains only letters (a-zA-Z). Play: https://go.dev/play/p/7Q5sGOz2izQ
func IsBase64 ¶
IsBase64 check if the string is base64 string. Play: https://go.dev/play/p/sWHEySAt6hl
func IsChineseIdNum ¶
IsChineseIdNum check if the string is chinese id card. Play: https://go.dev/play/p/d8EWhl2UGDF
func IsChineseMobile ¶
IsChineseMobile check if the string is chinese mobile number. Play: https://go.dev/play/p/GPYUlGTOqe3
func IsChinesePhone ¶
IsChinesePhone check if the string is chinese phone number. Valid chinese phone is xxx-xxxxxxxx or xxxx-xxxxxxx. Play: https://go.dev/play/p/RUD_-7YZJ3I
func IsCreditCard ¶
IsCreditCard check if the string is credit card. Play: https://go.dev/play/p/sNwwL6B0-v4
func IsDns ¶
IsDns check if the string is dns. Play: https://go.dev/play/p/jlYApVLLGTZ
func IsEmail ¶
IsEmail check if the string is a email address. Play: https://go.dev/play/p/Os9VaFlT33G
func IsEmptyString ¶
IsEmptyString check if the string is empty. Play: https://go.dev/play/p/dpzgUjFnBCX
func IsFloat ¶
IsFloat check if the value is float(float32, float34) or not. Play: https://go.dev/play/p/vsyG-sxr99_Z
func IsFloatStr ¶
IsFloatStr check if the string can convert to a float. Play: https://go.dev/play/p/LOYwS_Oyl7U
func IsGBK ¶
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 IsInt ¶
IsInt check if the value is integer(int, unit) or not. Play: https://go.dev/play/p/eFoIHbgzl-z
func IsIntStr ¶
IsIntStr check if the string can convert to a integer. Play: https://go.dev/play/p/jQRtFv-a0Rk
func IsIp ¶
IsIp check if the string is a ip address. Play: https://go.dev/play/p/FgcplDvmxoD
func IsIpV4 ¶
IsIpV4 check if the string is a ipv4 address. Play: https://go.dev/play/p/zBGT99EjaIu
func IsIpV6 ¶
IsIpV6 check if the string is a ipv6 address. Play: https://go.dev/play/p/AHA0r0AzIdC
func IsJSON ¶
IsJSON checks if the string is valid JSON. Play: https://go.dev/play/p/8Kip1Itjiil
func IsNumber ¶
IsNumberStr check if the value is number(integer, float) or not. Play: https://go.dev/play/p/mdJHOAvtsvF
func IsNumberStr ¶
IsNumberStr check if the string can convert to a number. Play: https://go.dev/play/p/LzaKocSV79u
func IsPrintable ¶
IsPrintable checks if string is all printable chars. Play: https://go.dev/play/p/Pe1FE2gdtTP
func IsRegexMatch ¶
IsRegexMatch check if the string match the regexp. Play: https://go.dev/play/p/z_XeZo_litG
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(!@#$%^&*()?><). Play: https://go.dev/play/p/QHdVcSQ3uDg
func IsUrl ¶
IsUrl check if the string is url. Play: https://go.dev/play/p/pbJGa7F98Ka
func IsWeakPassword ¶
IsWeakPassword check if the string is weak password Weak password: only letter or only number or letter + number. Play: https://go.dev/play/p/wqakscZH5gH
func IsZeroValue ¶
IsZeroValue checks if value is a zero value. Play: https://go.dev/play/p/UMrwaDCi_t4
Types ¶
This section is empty.