udemy-go-web-1/internal/forms/errors.go
2024-06-30 17:08:47 +02:00

19 lines
335 B
Go

package forms
type errors map[string][]string
// Add adds an error message for a given form field
func (e errors) Add(field, message string) {
e[field] = append(e[field], message)
}
// Get returns the first error message
func (e errors) Get(field string) string {
es := e[field]
if len(es) == 0 {
return ""
}
return es[0]
}