feat: initial commit
This commit is contained in:
22
internal/http/form/non_empty.go
Normal file
22
internal/http/form/non_empty.go
Normal file
@ -0,0 +1,22 @@
|
||||
package form
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func NonEmpty(message string) func(f *Field) error {
|
||||
return func(f *Field) error {
|
||||
value, err := FieldAttr[string](f, "value")
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(value) == "" {
|
||||
return NewValidationError(message)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user