Make IsValidPercent return error strings

This commit is contained in:
Tim Hockin
2016-01-28 23:22:57 -08:00
parent 87c1fc50a8
commit bb208a02b3
4 changed files with 48 additions and 6 deletions

View File

@@ -221,8 +221,11 @@ const percentFmt string = "[0-9]+%"
var percentRegexp = regexp.MustCompile("^" + percentFmt + "$")
func IsValidPercent(percent string) bool {
return percentRegexp.MatchString(percent)
func IsValidPercent(percent string) []string {
if !percentRegexp.MatchString(percent) {
return []string{RegexError(percentFmt, "1%", "93%")}
}
return nil
}
const HTTPHeaderNameFmt string = "[-A-Za-z0-9]+"