Documentation ¶
Index ¶
- Variables
- func Alpha(fieldExpr string) *regexRule
- func AlphaNumeric(fieldExpr string) *regexRule
- func And(rules ...Rule) *andRule
- func Array(fieldExpr string, innerRule Rule) *arrayRule
- func CrossComp(fieldExprLeft string, fieldExprRight string, op operand) *crossFieldCompareRule
- func Custom(fieldExpr string, checkFn func(exprValue interface{}) (bool, string)) *customRule
- func Dir(fieldExpr string) *dirRule
- func Email(fieldExpr string) *regexRule
- func EndsWith(fieldExpr string, suffix string) *endsWithRule
- func EqComp(filedExpr string, equivalent Comparable) *eqRuleComp
- func EqFloat(filedExpr string, equivalent float64) *eqRuleFloat
- func EqInt(filedExpr string, equivalent int) *eqRuleInt
- func EqStr(filedExpr string, equivalent string) *eqRuleString
- func EqTime(filedExpr string, equivalent time.Time) *eqRuleTime
- func EqTimeStr(filedExpr string, layout string, equivalent time.Time) *eqRuleTimeStr
- func EqUint(filedExpr string, equivalent uint) *eqRuleUint
- func Field(fieldExpr string, subRule Rule) *fieldRule
- func HTML(fieldExpr string) *regexRule
- func HTMLEncoded(fieldExpr string) *regexRule
- func HostName(fieldExpr string) *regexRule
- func IPv4(fieldExpr string) *ipv4Rule
- func IPv6(fieldExpr string) *ipv6Rule
- func ISBN(fieldExpr string) *iSBNRule
- func ISBN10(fieldExpr string) *iSBN10Rule
- func ISBN13(fieldExpr string) *iSBN13Rule
- func InFloat(filedExpr string, enum ...float64) *enumRuleFloat
- func InInt(filedExpr string, enum ...int) *enumRuleInt
- func InStr(filedExpr string, enum ...string) *enumRuleString
- func InUint(filedExpr string, enum ...uint) *enumRuleUint
- func Ip(fieldExpr string) *ipRule
- func JSON(fieldExpr string) *jsonRule
- func Length(fieldExpr string, ge int, le int) *lengthRule
- func Map(fieldExpr string, keyRule Rule, valueRule Rule) *mapRule
- func NeComp(filedExpr string, inequivalent Comparable) *neRuleComp
- func NeFloat(filedExpr string, inequivalent float64) *neRuleFloat
- func NeInt(filedExpr string, inequivalent int) *neRuleInt
- func NeStr(filedExpr string, inequivalent string) *neRuleString
- func NeTime(filedExpr string, inequivalent time.Time) *neRuleTime
- func NeTimeStr(filedExpr string, layout string, inequivalent time.Time) *neRuleTimeStr
- func NeUint(filedExpr string, inequivalent uint) *neRuleUint
- func Nil(fieldExpr string) *nilRule
- func Not(innerRule Rule) *notRule
- func Number(fieldExpr string) *regexRule
- func Numeric(fieldExpr string) *regexRule
- func Or(rules ...Rule) *orRule
- func RangeComp(filedExpr string, ge Comparable, le Comparable) *rangeRuleComp
- func RangeFloat(filedExpr string, ge float64, le float64) *rangeRuleFloat
- func RangeInt(filedExpr string, ge int, le int) *rangeRuleInt
- func RangeTime(filedExpr string, ge time.Time, le time.Time) *rangeRuleTime
- func RangeTimeStr(filedExpr string, layout string, ge time.Time, le time.Time) *rangeRuleTimeStr
- func RangeUint(filedExpr string, ge uint, le uint) *rangeRuleUint
- func Regex(fieldExpr string, regexExpr string) *regexRule
- func StartsWith(fieldExpr string, prefix string) *startsWithRule
- func Time(fieldExpr string, layout string) *timeRule
- func URI(fieldExpr string) *urlRule
- func URL(fieldExpr string) *urlRule
- func URLEncoded(fieldExpr string) *regexRule
- type Checker
- type Comparable
- type Rule
Constants ¶
This section is empty.
Variables ¶
var ( CrossFieldEq = eqOperand{} CrossFieldNe = neOperand{} CrossFieldGt = gtOperand{} CrossFieldGe = geOperand{} CrossFieldLt = ltOperand{} CrossFieldLe = leOperand{} )
cross field comparison operand variables
Functions ¶
func Alpha ¶
func Alpha(fieldExpr string) *regexRule
Alpha is the validation function for validating if the current field's value is a valid alpha value.
func AlphaNumeric ¶
func AlphaNumeric(fieldExpr string) *regexRule
AlphaNumeric is the validation function for validating if the current field's value is a valid alphanumeric value.
func And ¶
func And(rules ...Rule) *andRule
And accepts slice of rules It passed when all rules passed
func CrossComp ¶
CrossComp checks if left and right fields are same types and satisfy the comparison operand
func Dir ¶
func Dir(fieldExpr string) *dirRule
Dir is the validation function for validating if the current field's value is a valid directory.
func Email ¶
func Email(fieldExpr string) *regexRule
Email is the validation function for validating if the current field's value is a valid email address.
func EndsWith ¶
EndsWith is the validation function for validating that the field's value ends with the text specified within the param.
func EqComp ¶
func EqComp(filedExpr string, equivalent Comparable) *eqRuleComp
EqComp checks if the field is Comparable and is equal to given Comparable variable
func EqFloat ¶
EqFloat is the validation function for validating if the field's value is equal to given float.
func EqInt ¶
EqInt is the validation function for validating if the field's value is equal to given int.
func EqStr ¶
EqStr is the validation function for validating if the field's value is equal to given string.
func EqTime ¶
EqTime is the validation function for validating if the field's value is equal to given timestamp.
func EqTimeStr ¶
EqTimeStr is the validation function for validating if the field's value string and is equal to given timestamp.
func EqUint ¶
EqUint is the validation function for validating if the field's value is equal to given uint.
func HTML ¶
func HTML(fieldExpr string) *regexRule
HTML is the validation function for validating if the current field's value is a valid HTML.
func HTMLEncoded ¶
func HTMLEncoded(fieldExpr string) *regexRule
HTMLEncoded is the validation function for validating if the current field's value is a valid encoded HTML.
func HostName ¶
func HostName(fieldExpr string) *regexRule
HostName is the validation function for validating if the current field's value is a valid RFC953 hostname.
func IPv4 ¶
func IPv4(fieldExpr string) *ipv4Rule
IPv4 is the validation function for validating if a value is a valid v4 IP address.
func IPv6 ¶
func IPv6(fieldExpr string) *ipv6Rule
IPv6 is the validation function for validating if the field's value is a valid v6 IP address.
func ISBN ¶
func ISBN(fieldExpr string) *iSBNRule
ISBN is the validation function for validating if the field's value is a valid v10 or v13 ISBN.
func ISBN10 ¶
func ISBN10(fieldExpr string) *iSBN10Rule
ISBN10 is the validation function for validating if the field's value is a valid v10 ISBN.
func ISBN13 ¶
func ISBN13(fieldExpr string) *iSBN13Rule
ISBN13 is the validation function for validating if the field's value is a valid v13 ISBN.
func Ip ¶
func Ip(fieldExpr string) *ipRule
Ip is the validation function for validating if the field's value is a valid v4 or v6 IP address.
func JSON ¶
func JSON(fieldExpr string) *jsonRule
JSON is the validation function for validating if the current field's value is a valid json string.
func Length ¶
Length checks if the filed is slice/array/string/map and its length is between [ge,le]
func NeComp ¶
func NeComp(filedExpr string, inequivalent Comparable) *neRuleComp
NeComp checks if the field is Comparable and is not equal to given Comparable variable
func NeFloat ¶
NeFloat is the validation function for validating if the field's value is not equal to given float.
func NeInt ¶
NeInt is the validation function for validating if the field's value is not equal to given int.
func NeStr ¶
NeStr is the validation function for validating if the field's value is not equal to given string.
func NeTime ¶
NeTime is the validation function for validating if the field's value is not equal to given timestamp.
func NeTimeStr ¶
NeTimeStr is the validation function for validating if the field's value string and is not equal to given timestamp.
func NeUint ¶
NeUint is the validation function for validating if the field's value is not equal to given uint.
func Number ¶
func Number(fieldExpr string) *regexRule
Number is the validation function for validating if the current field's value is a valid number.
func Numeric ¶
func Numeric(fieldExpr string) *regexRule
Numeric is the validation function for validating if the current field's value is a valid numeric value.
func RangeComp ¶
func RangeComp(filedExpr string, ge Comparable, le Comparable) *rangeRuleComp
RangeComp checks if the value is between [ge,le]
func RangeFloat ¶
RangeFloat is the validation function for validating if the field's value is in given range.
func RangeInt ¶
RangeInt is the validation function for validating if the field's value is in given range.
func RangeTime ¶
RangeTime is the validation function for validating if the field's value is in given range.
func RangeTimeStr ¶
RangeTimeStr is the validation function for validating if the field's value is in given range.
func RangeUint ¶
RangeUint is the validation function for validating if the field's value is in given range.
func Regex ¶
Regex is the validation function for validating if the current field's value satisfies regex pattern.
func StartsWith ¶
StartsWith is the validation function for validating that the field's value starts with the text specified within the param.
func Time ¶
Time is the validation function for validating if the current field's value is a valid datetime string.
func URI ¶
func URI(fieldExpr string) *urlRule
URI is the validation function for validating if the current field's value is a valid URI.
func URL ¶
func URL(fieldExpr string) *urlRule
URL is the validation function for validating if the current field's value is a valid URL.
func URLEncoded ¶
func URLEncoded(fieldExpr string) *regexRule
URLEncoded is the validation function for validating if the current field's value is a valid encoded URL.
Types ¶
type Checker ¶
type Checker interface { Add(rule Rule, prompt string) Check(param interface{}) (bool, string, string) }
Checker is the representation of validation object
type Comparable ¶
Comparable is the interface for sturcts to be compared in CrossComp
type Rule ¶
type Rule interface { Check(param interface{}) (bool, string) Prompt(prompt string) Rule // contains filtered or unexported methods }
Rule represents the restriction of param should satisfy
func HostNameRFC1123 ¶
HostNameRFC1123 is the validation function for validating if the current field's value is a valid RFC1123 hostname.