|
|
@ -11,6 +11,7 @@ import ( |
|
|
|
"net/url" |
|
|
|
"net/url" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"reflect" |
|
|
|
"reflect" |
|
|
|
|
|
|
|
"regexp" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
@ -133,6 +134,7 @@ var ( |
|
|
|
"endswith": endsWith, |
|
|
|
"endswith": endsWith, |
|
|
|
"startsnotwith": startsNotWith, |
|
|
|
"startsnotwith": startsNotWith, |
|
|
|
"endsnotwith": endsNotWith, |
|
|
|
"endsnotwith": endsNotWith, |
|
|
|
|
|
|
|
"regex": regex, |
|
|
|
"isbn": isISBN, |
|
|
|
"isbn": isISBN, |
|
|
|
"isbn10": isISBN10, |
|
|
|
"isbn10": isISBN10, |
|
|
|
"isbn13": isISBN13, |
|
|
|
"isbn13": isISBN13, |
|
|
@ -767,6 +769,11 @@ func fieldExcludes(fl FieldLevel) bool { |
|
|
|
return !strings.Contains(field.String(), currentField.String()) |
|
|
|
return !strings.Contains(field.String(), currentField.String()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func regex(fl FieldLevel) bool { |
|
|
|
|
|
|
|
regex := regexp.MustCompile(fl.Param()) |
|
|
|
|
|
|
|
return regex.MatchString(fl.Field().String()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// IsNeField is the validation function for validating if the current field's value is not equal to the field specified by the param's value.
|
|
|
|
// IsNeField is the validation function for validating if the current field's value is not equal to the field specified by the param's value.
|
|
|
|
func isNeField(fl FieldLevel) bool { |
|
|
|
func isNeField(fl FieldLevel) bool { |
|
|
|
|
|
|
|
|
|
|
|