Documentation
¶
Index ¶
- func Abs(value float64) float64
- func ByteLength(str string, params ...string) bool
- func HasLowerCase(str string) bool
- func HasUpperCase(str string) bool
- func HasWhitespace(str string) bool
- func HasWhitespaceOnly(str string) bool
- func InRange(value, left, right any) bool
- func IsASCII(str string) bool
- func IsAlpha(str string) bool
- func IsAlphanumeric(str string) bool
- func IsBase64(str string) bool
- func IsByteLength(str string, min, max int) bool
- func IsCIDR(str string) bool
- func IsCRC32(str string) bool
- func IsCRC32b(str string) bool
- func IsCreditCard(str string) bool
- func IsDNSName(str string) bool
- func IsDataURI(str string) bool
- func IsDialString(str string) bool
- func IsDivisibleBy(str, num string) bool
- func IsE164(str string) bool
- func IsEmail(str string) bool
- func IsExistingEmail(email string) bool
- func IsFloat(str string) bool
- func IsHash(str string, algorithm string) bool
- func IsHexadecimal(str string) bool
- func IsHexcolor(str string) bool
- func IsHost(str string) bool
- func IsIMEI(str string) bool
- func IsIMSI(str string) bool
- func IsIP(str string) bool
- func IsIPv4(str string) bool
- func IsIPv6(str string) bool
- func IsISO3166Alpha2(str string) bool
- func IsISO3166Alpha3(str string) bool
- func IsISO4217(str string) bool
- func IsISO693Alpha2(str string) bool
- func IsISO693Alpha3b(str string) bool
- func IsIn(str string, params ...string) bool
- func IsInRaw(str string, params ...string) bool
- func IsInt(str string) bool
- func IsJSON(str string) bool
- func IsLatitude(str string) bool
- func IsLongitude(str string) bool
- func IsLowerCase(str string) bool
- func IsMAC(str string) bool
- func IsMD4(str string) bool
- func IsMD5(str string) bool
- func IsMongoID(str string) bool
- func IsMultibyte(str string) bool
- func IsNatural(value float64) bool
- func IsNegative(value float64) bool
- func IsNonNegative(value float64) bool
- func IsNonPositive(value float64) bool
- func IsNotNull(str string) bool
- func IsNull(str string) bool
- func IsNumeric(str string) bool
- func IsPort(str string) bool
- func IsPositive(value float64) bool
- func IsPrintableASCII(str string) bool
- func IsRFC3339(str string) bool
- func IsRFC3339WithoutZone(str string) bool
- func IsRGBcolor(str string) bool
- func IsRegex(str string) bool
- func IsRequestURI(rawurl string) bool
- func IsRequestURL(rawurl string) bool
- func IsRipeMD128(str string) bool
- func IsRipeMD160(str string) bool
- func IsSHA1(str string) bool
- func IsSHA256(str string) bool
- func IsSHA3224(str string) bool
- func IsSHA3256(str string) bool
- func IsSHA3384(str string) bool
- func IsSHA3512(str string) bool
- func IsSHA384(str string) bool
- func IsSHA512(str string) bool
- func IsSSN(str string) bool
- func IsSemver(str string) bool
- func IsSnakeCase(str string) bool
- func IsTiger128(str string) bool
- func IsTiger160(str string) bool
- func IsTiger192(str string) bool
- func IsTime(str string, format string) bool
- func IsType(v any, params ...string) bool
- func IsURL(str string) bool
- func IsUTFDigit(str string) bool
- func IsUTFLetter(str string) bool
- func IsUTFLetterNumeric(str string) bool
- func IsUTFNumeric(str string) bool
- func IsUUID(str string) bool
- func IsUUIDv3(str string) bool
- func IsUUIDv4(str string) bool
- func IsUUIDv5(str string) bool
- func IsUnixFilePath(str string) bool
- func IsUnixTime(str string) bool
- func IsUpperCase(str string) bool
- func IsWhole(value float64) bool
- func IsWinFilePath(str string) bool
- func Matches(str, pattern string) bool
- func Max(str string, params ...string) bool
- func MaxStringLength(str string, params ...string) bool
- func Min(str string, params ...string) bool
- func MinStringLength(str string, params ...string) bool
- func Range(str string, params ...string) bool
- func Register(name, format string, fn Func)
- func RuneLength(str string, params ...string) bool
- func Sign(value float64) float64
- func StringLength(str string, params ...string) bool
- func StringMatches(s string, params ...string) bool
- func Struct(s interface{}) (bool, error)
- type Error
- type Errors
- type Func
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteLength ¶
ByteLength checks string's length
func HasLowerCase ¶
HasLowerCase checks if the string contains at least 1 lowercase. Empty string is valid.
func HasUpperCase ¶
HasUpperCase checks if the string contains as least 1 uppercase. Empty string is valid.
func HasWhitespace ¶
HasWhitespace checks if the string contains any whitespace
func HasWhitespaceOnly ¶
HasWhitespaceOnly checks the string only contains whitespace
func InRange ¶
InRange returns true if value lies between left and right border, generic type to handle int, float32, float64 and string. All types must the same type. False if value doesn't lie in range or if it incompatible or not comparable
func IsAlphanumeric ¶
IsAlphanumeric checks if the string contains only letters and numbers. Empty string is valid.
func IsByteLength ¶
IsByteLength checks if the string's length (in bytes) falls in a range.
func IsCreditCard ¶
IsCreditCard checks if the string is a credit card.
func IsDialString ¶
IsDialString validates the given string for usage with the various Dial() functions
func IsDivisibleBy ¶
IsDivisibleBy checks if the string is a number that's divisible by another. If second argument is not valid integer or zero, it's return false. Otherwise, if first argument is not valid integer or zero, it's return true (Invalid string converts to zero).
func IsExistingEmail ¶
IsExistingEmail checks if the string is an email of existing domain
func IsHash ¶
IsHash checks if a string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
func IsHexadecimal ¶
IsHexadecimal checks if the string is a hexadecimal number.
func IsHexcolor ¶
IsHexcolor checks if the string is a hexadecimal color.
func IsISO3166Alpha2 ¶
IsISO3166Alpha2 checks if a string is valid two-letter country code
func IsISO3166Alpha3 ¶
IsISO3166Alpha3 checks if a string is valid three-letter country code
func IsISO693Alpha2 ¶
IsISO693Alpha2 checks if a string is valid two-letter language code
func IsISO693Alpha3b ¶
IsISO693Alpha3b checks if a string is valid three-letter language code
func IsLongitude ¶
IsLongitude checks if a string is valid longitude.
func IsLowerCase ¶
IsLowerCase checks if the string is lowercase. Empty string is valid.
func IsMAC ¶
IsMAC checks if a string is valid MAC address. Possible MAC formats: 01:23:45:67:89:ab 01:23:45:67:89:ab:cd:ef 01-23-45-67-89-ab 01-23-45-67-89-ab-cd-ef 0123.4567.89ab 0123.4567.89ab.cdef
func IsMongoID ¶
IsMongoID checks if the string is a valid hex-encoded representation of a MongoDB ObjectId.
func IsMultibyte ¶
IsMultibyte checks if the string contains one or more multibyte chars. Empty string is valid.
func IsNonNegative ¶
IsNonNegative returns true if value >= 0
func IsNonPositive ¶
IsNonPositive returns true if value <= 0
func IsPrintableASCII ¶
IsPrintableASCII checks if the string contains printable ASCII chars only. Empty string is valid.
func IsRFC3339WithoutZone ¶
IsRFC3339WithoutZone checks if string is valid timestamp value according to RFC3339 which excludes the timezone.
func IsRGBcolor ¶
IsRGBcolor checks if the string is a valid RGB color in form rgb(RRR, GGG, BBB).
func IsRequestURI ¶
IsRequestURI checks if the string rawurl, assuming it was received in an HTTP request, is an absolute URI or an absolute path.
func IsRequestURL ¶
IsRequestURL checks if the string rawurl, assuming it was received in an HTTP request, is a valid URL confirm to RFC 3986
func IsRipeMD128 ¶
IsRipeMD128 checks is a string is a RipeMD128 hash. Alias for `IsHash(str, "ripemd128")`
func IsRipeMD160 ¶
IsRipeMD160 checks is a string is a RipeMD160 hash. Alias for `IsHash(str, "ripemd160")`
func IsSHA3224 ¶
IsSHA3224 checks is a string is a SHA3-224 hash. Alias for `IsHash(str, "sha3-224")`
func IsSHA3256 ¶
IsSHA3256 checks is a string is a SHA3-256 hash. Alias for `IsHash(str, "sha3-256")`
func IsSHA3384 ¶
IsSHA3384 checks is a string is a SHA3-384 hash. Alias for `IsHash(str, "sha3-384")`
func IsSHA3512 ¶
IsSHA3512 checks is a string is a SHA3-512 hash. Alias for `IsHash(str, "sha3-512")`
func IsSnakeCase ¶ added in v0.0.3
func IsTiger128 ¶
IsTiger128 checks is a string is a Tiger128 hash. Alias for `IsHash(str, "tiger128")`
func IsTiger160 ¶
IsTiger160 checks is a string is a Tiger160 hash. Alias for `IsHash(str, "tiger160")`
func IsTiger192 ¶
IsTiger192 checks is a string is a Tiger192 hash. Alias for `IsHash(str, "tiger192")`
func IsUTFDigit ¶
IsUTFDigit checks if the string contains only unicode radix-10 decimal digits. Empty string is valid.
func IsUTFLetter ¶
IsUTFLetter checks if the string contains only unicode letter characters. Similar to IsAlpha but for all languages. Empty string is valid.
func IsUTFLetterNumeric ¶
IsUTFLetterNumeric checks if the string contains only unicode letters and numbers. Empty string is valid.
func IsUTFNumeric ¶
IsUTFNumeric checks if the string contains only unicode numbers of any kind. Numbers can be 0-9 but also Fractions ¾,Roman Ⅸ and Hangzhou 〩. Empty string is valid.
func IsUnixFilePath ¶
IsUnixFilePath checks both relative & absolute paths in Unix
func IsUnixTime ¶
IsUnixTime checks if string is valid unix timestamp value
func IsUpperCase ¶
IsUpperCase checks if the string is uppercase. Empty string is valid.
func IsWinFilePath ¶
IsWinFilePath checks both relative & absolute paths in Windows
func Matches ¶
Matches checks if string matches the pattern (pattern is regular expression) In case of error return false
func Max ¶
Max checks whether the value is less than or equal to the maximum value. If the value is not a number, it will be converted to a number before comparison.
func MaxStringLength ¶
MaxStringLength checks string's maximum length (including multi byte strings)
func Min ¶
Min checks whether the value is greater than or equal to the minimum value. If the value is not a number, it will be converted to a number before comparison.
func MinStringLength ¶
MinStringLength checks string's minimum length (including multi byte strings)
func RuneLength ¶
RuneLength checks string's length Alias for StringLength
func Sign ¶
Sign returns signum of number: 1 in case of value > 0, -1 in case of value < 0, 0 otherwise
func StringLength ¶
StringLength checks string's length (including multi byte strings)
func StringMatches ¶
StringMatches checks if a string matches a given pattern.
Types ¶
type Error ¶
type Error struct { Name string Validator string Path []string // contains filtered or unexported fields }
Error encapsulates a name, an error and whether there's a custom error message or not.