|
|
@ -54,7 +54,6 @@ func isURI(top interface{}, current interface{}, field interface{}, param string |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isURL(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isURL(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
|
|
|
|
st := reflect.ValueOf(field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
switch st.Kind() { |
|
|
@ -77,146 +76,47 @@ func isURL(top interface{}, current interface{}, field interface{}, param string |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isEmail(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isEmail(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(emailRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return emailRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isHsla(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isHsla(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(hslaRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return hslaRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isHsl(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isHsl(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(hslRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return hslRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isRgba(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isRgba(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(rgbaRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return rgbaRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isRgb(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isRgb(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(rgbRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return rgbRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isHexcolor(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isHexcolor(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(hexcolorRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return hexcolorRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isHexadecimal(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isHexadecimal(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(hexadecimalRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return hexadecimalRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isNumber(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isNumber(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(numberRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return numberRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isNumeric(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isNumeric(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(numericRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return numericRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isAlphanum(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isAlphanum(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(alphaNumericRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return alphaNumericRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isAlpha(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func isAlpha(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
|
|
|
|
return matchesRegex(alphaRegex, field) |
|
|
|
st := reflect.ValueOf(field) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch st.Kind() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case reflect.String: |
|
|
|
|
|
|
|
return alphaRegex.MatchString(field.(string)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
panic(fmt.Sprintf("Bad field type %T", field)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func hasValue(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
|
func hasValue(top interface{}, current interface{}, field interface{}, param string) bool { |
|
|
@ -767,10 +667,7 @@ func hasMaxOf(top interface{}, current interface{}, field interface{}, param str |
|
|
|
func asInt(param string) int64 { |
|
|
|
func asInt(param string) int64 { |
|
|
|
|
|
|
|
|
|
|
|
i, err := strconv.ParseInt(param, 0, 64) |
|
|
|
i, err := strconv.ParseInt(param, 0, 64) |
|
|
|
|
|
|
|
panifIf(err) |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
panic(err.Error()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return i |
|
|
|
return i |
|
|
|
} |
|
|
|
} |
|
|
@ -780,10 +677,7 @@ func asInt(param string) int64 { |
|
|
|
func asUint(param string) uint64 { |
|
|
|
func asUint(param string) uint64 { |
|
|
|
|
|
|
|
|
|
|
|
i, err := strconv.ParseUint(param, 0, 64) |
|
|
|
i, err := strconv.ParseUint(param, 0, 64) |
|
|
|
|
|
|
|
panifIf(err) |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
panic(err.Error()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return i |
|
|
|
return i |
|
|
|
} |
|
|
|
} |
|
|
@ -793,10 +687,13 @@ func asUint(param string) uint64 { |
|
|
|
func asFloat(param string) float64 { |
|
|
|
func asFloat(param string) float64 { |
|
|
|
|
|
|
|
|
|
|
|
i, err := strconv.ParseFloat(param, 64) |
|
|
|
i, err := strconv.ParseFloat(param, 64) |
|
|
|
|
|
|
|
panifIf(err) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return i |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func panifIf(err error) { |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
panic(err.Error()) |
|
|
|
panic(err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return i |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|