added team view to season_leagues

This commit is contained in:
2026-02-20 19:57:06 +11:00
parent c3d8e6c675
commit 7ea21c63e4
25 changed files with 1018 additions and 51 deletions

View File

@@ -0,0 +1,24 @@
package validation
import (
"fmt"
"strconv"
)
type BoolField struct {
FieldBase
Value bool
}
func newBoolField(key string, g Getter) *BoolField {
raw := g.Get(key)
val, err := strconv.ParseBool(raw)
if err != nil {
g.AddCheck(newFailedCheck("Invalid boolean value",
fmt.Sprintf("Field %s requires a boolean value, %s given", key, raw)))
}
return &BoolField{
newField(key, g),
val,
}
}

View File

@@ -27,7 +27,18 @@ func (f *FormGetter) Get(key string) string {
}
func (f *FormGetter) GetList(key string) []string {
return strings.Split(f.Get(key), ",")
if f.r.Form == nil {
return nil
}
values, ok := f.r.Form[key]
if !ok || len(values) == 0 {
return nil
}
// Support both comma-separated single values and multiple form fields
if len(values) == 1 {
return strings.Split(values[0], ",")
}
return values
}
func (f *FormGetter) GetMaps(key string) []map[string]string {
@@ -72,6 +83,10 @@ func (f *FormGetter) Int(key string) *IntField {
return newIntField(key, f)
}
func (f *FormGetter) Bool(key string) *BoolField {
return newBoolField(key, f)
}
func (f *FormGetter) Time(key string, format *timefmt.Format) *TimeField {
return newTimeField(key, format, f)
}

View File

@@ -46,6 +46,10 @@ func (q *QueryGetter) Int(key string) *IntField {
return newIntField(key, q)
}
func (q *QueryGetter) Bool(key string) *BoolField {
return newBoolField(key, q)
}
func (q *QueryGetter) Time(key string, format *timefmt.Format) *TimeField {
return newTimeField(key, format, q)
}

View File

@@ -25,6 +25,7 @@ type Getter interface {
AddCheck(check *ValidationRule)
String(key string) *StringField
Int(key string) *IntField
Bool(key string) *BoolField
Time(key string, format *timefmt.Format) *TimeField
StringList(key string) *StringList
IntList(key string) *IntList