we have fixtures ladies and gentleman
This commit is contained in:
@@ -2,6 +2,8 @@ package validation
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.haelnorr.com/h/golib/hws"
|
||||
@@ -29,6 +31,22 @@ func (f *FormGetter) GetList(key string) []string {
|
||||
return strings.Split(f.Get(key), ",")
|
||||
}
|
||||
|
||||
func (f *FormGetter) GetMaps(key string) []map[string]string {
|
||||
var result []map[string]string
|
||||
for key, values := range f.r.Form {
|
||||
re := regexp.MustCompile(key + "\\[([0-9]+)\\]\\[([a-zA-Z]+)\\]")
|
||||
matches := re.FindStringSubmatch(key)
|
||||
if len(matches) >= 3 {
|
||||
index, _ := strconv.Atoi(matches[1])
|
||||
for index >= len(result) {
|
||||
result = append(result, map[string]string{})
|
||||
}
|
||||
result[index][matches[2]] = values[0]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (f *FormGetter) getChecks() []*ValidationRule {
|
||||
return f.checks
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user