diff --git a/webutil/formscanner.go b/webutil/formscanner.go index 5442ded..8cd17ac 100644 --- a/webutil/formscanner.go +++ b/webutil/formscanner.go @@ -8,17 +8,9 @@ import ( var ErrUnsupportedType = errors.New("unsupported type") -// FormScanFunc is a custom form scanner that can be used to scan custom -// types using the form scanner. -// -// It returns true if it recognizes the type of val, and an error if scanning -// fails. -type FormScanFunc func(name, formVal string, val any) (bool, error) - type FormScanner struct { - form url.Values - err error - ScanFunc FormScanFunc // TODO: Remove? + form url.Values + err error } func NewFormScanner(form url.Values) *FormScanner { @@ -30,13 +22,6 @@ func (s *FormScanner) Scan(name string, val any) *FormScanner { return s } - if s.ScanFunc != nil { - if ok, err := s.ScanFunc(name, s.form.Get(name), val); ok { - s.err = err - return s - } - } - switch v := val.(type) { case *bool: *v = s.form.Has(name) @@ -52,3 +37,7 @@ func (s *FormScanner) Scan(name string, val any) *FormScanner { func (s *FormScanner) Error() error { return s.err } + +func (s *FormScanner) SetError(err error) { + s.err = err +}