we have fixtures ladies and gentleman

This commit is contained in:
2026-02-15 19:56:03 +11:00
parent ef8c022e60
commit 0c5a88c309
23 changed files with 1355 additions and 78 deletions

View File

@@ -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
}