var fieldsRequiredByDefault … var nilPtrAllowedByRequired … var notNumberRegexp … var whiteSpacesAndMinus … var paramsRegexp … const maxURLRuneCount … const minURLRuneCount … const RF3339WithoutZone … // SetFieldsRequiredByDefault causes validation to fail when struct fields // do not include validations or are not explicitly marked as exempt (using `valid:"-"` or `valid:"email,optional"`). // This struct definition will fail govalidator.ValidateStruct() (and the field values do not matter): // type exampleStruct struct { // Name string `` // Email string `valid:"email"` // This, however, will only fail when Email is empty or an invalid email address: // type exampleStruct2 struct { // Name string `valid:"-"` // Email string `valid:"email"` // Lastly, this will only fail when Email is an invalid email address but not when it's empty: // type exampleStruct2 struct { // Name string `valid:"-"` // Email string `valid:"email,optional"` func SetFieldsRequiredByDefault(value bool) { … } // SetNilPtrAllowedByRequired causes validation to pass for nil ptrs when a field is set to required. // The validation will still reject ptr fields in their zero value state. Example with this enabled: // type exampleStruct struct { // Name *string `valid:"required"` // With `Name` set to "", this will be considered invalid input and will cause a validation error. // With `Name` set to nil, this will be considered valid by validation. // By default this is disabled. func SetNilPtrAllowedByRequired(value bool) { … } // IsEmail check if the string is an email. func IsEmail(str string) bool { … } // IsExistingEmail check if the string is an email of existing domain func IsExistingEmail(email string) bool { … } // IsURL check if the string is an URL. func IsURL(str string) bool { … } // IsRequestURL check if the string rawurl, assuming // it was received in an HTTP request, is a valid // URL confirm to RFC 3986 func IsRequestURL(rawurl string) bool { … } // IsRequestURI check if the string rawurl, assuming // it was received in an HTTP request, is an // absolute URI or an absolute path. func IsRequestURI(rawurl string) bool { … } // IsAlpha check if the string contains only letters (a-zA-Z). Empty string is valid. func IsAlpha(str string) bool { … } //IsUTFLetter check if the string contains only unicode letter characters. //Similar to IsAlpha but for all languages. Empty string is valid. func IsUTFLetter(str string) bool { … } // IsAlphanumeric check if the string contains only letters and numbers. Empty string is valid. func IsAlphanumeric(str string) bool { … } // IsUTFLetterNumeric check if the string contains only unicode letters and numbers. Empty string is valid. func IsUTFLetterNumeric(str string) bool { … } // IsNumeric check if the string contains only numbers. Empty string is valid. func IsNumeric(str string) bool { … } // IsUTFNumeric check 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 IsUTFNumeric(str string) bool { … } // IsUTFDigit check if the string contains only unicode radix-10 decimal digits. Empty string is valid. func IsUTFDigit(str string) bool { … } // IsHexadecimal check if the string is a hexadecimal number. func IsHexadecimal(str string) bool { … } // IsHexcolor check if the string is a hexadecimal color. func IsHexcolor(str string) bool { … } // IsRGBcolor check if the string is a valid RGB color in form rgb(RRR, GGG, BBB). func IsRGBcolor(str string) bool { … } // IsLowerCase check if the string is lowercase. Empty string is valid. func IsLowerCase(str string) bool { … } // IsUpperCase check if the string is uppercase. Empty string is valid. func IsUpperCase(str string) bool { … } // HasLowerCase check if the string contains at least 1 lowercase. Empty string is valid. func HasLowerCase(str string) bool { … } // HasUpperCase check if the string contians as least 1 uppercase. Empty string is valid. func HasUpperCase(str string) bool { … } // IsInt check if the string is an integer. Empty string is valid. func IsInt(str string) bool { … } // IsFloat check if the string is a float. func IsFloat(str string) bool { … } // IsDivisibleBy check 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 IsDivisibleBy(str, num string) bool { … } // IsNull check if the string is null. func IsNull(str string) bool { … } // HasWhitespaceOnly checks the string only contains whitespace func HasWhitespaceOnly(str string) bool { … } // HasWhitespace checks if the string contains any whitespace func HasWhitespace(str string) bool { … } // IsByteLength check if the string's length (in bytes) falls in a range. func IsByteLength(str string, min, max int) bool { … } // IsUUIDv3 check if the string is a UUID version 3. func IsUUIDv3(str string) bool { … } // IsUUIDv4 check if the string is a UUID version 4. func IsUUIDv4(str string) bool { … } // IsUUIDv5 check if the string is a UUID version 5. func IsUUIDv5(str string) bool { … } // IsUUID check if the string is a UUID (version 3, 4 or 5). func IsUUID(str string) bool { … } // IsCreditCard check if the string is a credit card. func IsCreditCard(str string) bool { … } // IsISBN10 check if the string is an ISBN version 10. func IsISBN10(str string) bool { … } // IsISBN13 check if the string is an ISBN version 13. func IsISBN13(str string) bool { … } // IsISBN check if the string is an ISBN (version 10 or 13). // If version value is not equal to 10 or 13, it will be check both variants. func IsISBN(str string, version int) bool { … } // IsJSON check if the string is valid JSON (note: uses json.Unmarshal). func IsJSON(str string) bool { … } // IsMultibyte check if the string contains one or more multibyte chars. Empty string is valid. func IsMultibyte(str string) bool { … } // IsASCII check if the string contains ASCII chars only. Empty string is valid. func IsASCII(str string) bool { … } // IsPrintableASCII check if the string contains printable ASCII chars only. Empty string is valid. func IsPrintableASCII(str string) bool { … } // IsFullWidth check if the string contains any full-width chars. Empty string is valid. func IsFullWidth(str string) bool { … } // IsHalfWidth check if the string contains any half-width chars. Empty string is valid. func IsHalfWidth(str string) bool { … } // IsVariableWidth check if the string contains a mixture of full and half-width chars. Empty string is valid. func IsVariableWidth(str string) bool { … } // IsBase64 check if a string is base64 encoded. func IsBase64(str string) bool { … } // IsFilePath check is a string is Win or Unix file path and returns it's type. func IsFilePath(str string) (bool, int) { … } // IsDataURI checks if a string is base64 encoded data URI such as an image func IsDataURI(str string) bool { … } // IsISO3166Alpha2 checks if a string is valid two-letter country code func IsISO3166Alpha2(str string) bool { … } // IsISO3166Alpha3 checks if a string is valid three-letter country code func IsISO3166Alpha3(str string) bool { … } // IsISO693Alpha2 checks if a string is valid two-letter language code func IsISO693Alpha2(str string) bool { … } // IsISO693Alpha3b checks if a string is valid three-letter language code func IsISO693Alpha3b(str string) bool { … } // IsDNSName will validate the given string as a DNS name func IsDNSName(str string) bool { … } // 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 IsHash(str string, algorithm string) bool { … } // IsDialString validates the given string for usage with the various Dial() functions func IsDialString(str string) bool { … } // IsIP checks if a string is either IP version 4 or 6. func IsIP(str string) bool { … } // IsPort checks if a string represents a valid port func IsPort(str string) bool { … } // IsIPv4 check if the string is an IP version 4. func IsIPv4(str string) bool { … } // IsIPv6 check if the string is an IP version 6. func IsIPv6(str string) bool { … } // IsCIDR check if the string is an valid CIDR notiation (IPV4 & IPV6) func IsCIDR(str string) bool { … } // IsMAC check 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 IsMAC(str string) bool { … } // IsHost checks if the string is a valid IP (both v4 and v6) or a valid DNS name func IsHost(str string) bool { … } // IsMongoID check if the string is a valid hex-encoded representation of a MongoDB ObjectId. func IsMongoID(str string) bool { … } // IsLatitude check if a string is valid latitude. func IsLatitude(str string) bool { … } // IsLongitude check if a string is valid longitude. func IsLongitude(str string) bool { … } // IsRsaPublicKey check if a string is valid public key with provided length func IsRsaPublicKey(str string, keylen int) bool { … } func toJSONName(tag string) string { … } func PrependPathToErrors(err error, path string) error { … } // ValidateStruct use tags for fields. // result will be equal to `false` if there are any errors. func ValidateStruct(s interface{ … } // parseTagIntoMap parses a struct tag `valid:required~Some error message,length(2|3)` into map[string]string{"required": "Some error message", "length(2|3)": ""} func parseTagIntoMap(tag string) tagOptionsMap { … } func isValidTag(s string) bool { … } // IsSSN will validate the given string as a U.S. Social Security Number func IsSSN(str string) bool { … } // IsSemver check if string is valid semantic version func IsSemver(str string) bool { … } // IsTime check if string is valid according to given format func IsTime(str string, format string) bool { … } // IsRFC3339 check if string is valid timestamp value according to RFC3339 func IsRFC3339(str string) bool { … } // IsRFC3339WithoutZone check if string is valid timestamp value according to RFC3339 which excludes the timezone. func IsRFC3339WithoutZone(str string) bool { … } // IsISO4217 check if string is valid ISO currency code func IsISO4217(str string) bool { … } // ByteLength check string's length func ByteLength(str string, params ...string) bool { … } // RuneLength check string's length // Alias for StringLength func RuneLength(str string, params ...string) bool { … } // IsRsaPub check whether string is valid RSA key // Alias for IsRsaPublicKey func IsRsaPub(str string, params ...string) bool { … } // StringMatches checks if a string matches a given pattern. func StringMatches(s string, params ...string) bool { … } // StringLength check string's length (including multi byte strings) func StringLength(str string, params ...string) bool { … } // Range check string's length func Range(str string, params ...string) bool { … } func isInRaw(str string, params ...string) bool { … } // IsIn check if string str is a member of the set of strings params func IsIn(str string, params ...string) bool { … } func checkRequired(v reflect.Value, t reflect.StructField, options tagOptionsMap) (bool, error) { … } func typeCheck(v reflect.Value, t reflect.StructField, o reflect.Value, options tagOptionsMap) (isValid bool, resultErr error) { … } func stripParams(validatorString string) string { … } func isEmptyValue(v reflect.Value) bool { … } // ErrorByField returns error for specified field of the struct // validated by ValidateStruct or empty string if there are no errors // or this field doesn't exists or doesn't have any errors. func ErrorByField(e error, field string) string { … } // ErrorsByField returns map of errors of the struct validated // by ValidateStruct or empty map if there are no errors. func ErrorsByField(e error) map[string]string { … } // Error returns string equivalent for reflect.Type func (e *UnsupportedTypeError) Error() string { … } func (sv stringValues) Len() int { … } func (sv stringValues) Swap(i, j int) { … } func (sv stringValues) Less(i, j int) bool { … } func (sv stringValues) get(i int) string { … }