Documentation ¶
Index ¶
- Variables
- func Between(a, b interface{}, msg string) validation.Rule
- func In(values []interface{}, msg string) validation.Rule
- func Max(max interface{}, msg string) validation.Rule
- func Min(min interface{}, msg string) validation.Rule
- func NotNil(msg string) validation.Rule
- func SliceEach(iter SliceIter, rules []validation.Rule) validation.Rule
- func SliceLen(min, max int, msg string) validation.Rule
- func SliceMaxLen(max int, msg string) validation.Rule
- func SliceMinLen(min int, msg string) validation.Rule
- func SliceUnique(iter SliceIter, msg string) validation.Rule
- func StrLen(min, max int, msg string) validation.Rule
- func StrMatch(pattern *regexp.Regexp, msg string) validation.Rule
- func StrMaxLen(max int, msg string) validation.Rule
- func StrMinLen(min int, msg string) validation.Rule
- func StrRequired(msg string) validation.Rule
- type SliceIter
Constants ¶
This section is empty.
Variables ¶
var ( ParamInUnsupported = "unsupported" ParamInSupported = "supported" )
var ( ParamNumMin = "min" ParamNumMax = "max" )
var ( ParamSliceMinLen = "minLen" ParamSliceMaxLen = "maxLen" )
var ( // ParamMaxLen is the name of string min length parameter. ParamStrMaxLen = "maxLen" // ParamMaxLen is the name of string max length parameter. ParamStrMinLen = "minLen" )
var ( // StrEmail creates validator to check whether a string is an email. StrEmail = fromfn(govalidator.IsEmail) // StrIPv4 creates validator to check whether a string is an IPv4. StrIPv4 = fromfn(govalidator.IsIPv4) // StrIPv6 creates validator to check whether a string is an IPv6. StrIPv6 = fromfn(govalidator.IsIPv6) // StrIP creates validator to check whether a string is an IP. StrIP = fromfn(govalidator.IsIP) // StrIsURL creates validator to check whether a string is an URL. StrIsURL = fromfn(govalidator.IsURL) // StrIsUpperCase creates validator to check whether a string is in upper case. StrIsUpperCase = fromfn(govalidator.IsUpperCase) // StrIsLowerCase creates validator to check whether a string is in lower case. StrIsLowerCase = fromfn(govalidator.IsLowerCase) // StrIsJSON creates validator to check whether a string is a JSON. StrIsJSON = fromfn(govalidator.IsJSON) )
Functions ¶
func Between ¶
func Between(a, b interface{}, msg string) validation.Rule
Between creates validator to check whether a number is the range provided.
func In ¶
func In(values []interface{}, msg string) validation.Rule
In creates a validator to chech wheter an item belongs to the set provided.
func Max ¶
func Max(max interface{}, msg string) validation.Rule
Max creates validator to check whether a number is not great than the value provided.
func Min ¶
func Min(min interface{}, msg string) validation.Rule
Min creates validator to check whether a number is not less than the value provided.
func NotNil ¶
func NotNil(msg string) validation.Rule
NotNil creates validator to check whether a value is nil.
func SliceEach ¶
func SliceEach(iter SliceIter, rules []validation.Rule) validation.Rule
SliceEach creates validator to check whether all items of a slice meet the rules provided.
func SliceMaxLen ¶
SliceMaxLen creates validator to check whether slice length is not less than the value provided.
func SliceMinLen ¶
SliceMinLen creates validator to check whether slice length is not less than the value provided.
func SliceUnique ¶
SliceUnique create validator to check wheter a slice contains only unique items.
func StrLen ¶
StrLen creates validator to check whether length of a string is in the range provided. The 'msg' parameter should be a format string with 2 slots for int.
func StrMatch ¶
StrMatch creates validator to check whether a string matches the regular expression provided.
func StrMaxLen ¶
StrMaxLen creates validator to check whether length of a string is not great than the value provided. The 'msg' parameter should be a format string with 1 slot for int.
func StrMinLen ¶
StrMinLen creates validator to check whether length of a string is not less than the value provided. The 'msg' parameter should be a format string with 1 slot for int.
func StrRequired ¶
func StrRequired(msg string) validation.Rule
StrRequired creates validator to check whether a string is blank.