blog/core/forms/settings.go

39 lines
661 B
Go
Raw Normal View History

2017-11-20 05:49:19 +00:00
package forms
import (
"errors"
"net/mail"
)
// Settings are the user-facing admin settings.
type Settings struct {
Title string
AdminEmail string
URL string
2017-11-20 05:49:19 +00:00
RedisEnabled bool
RedisHost string
RedisPort int
RedisDB int
RedisPrefix string
MailEnabled bool
MailSender string
MailHost string
MailPort int
MailUsername string
MailPassword string
2017-11-20 05:49:19 +00:00
}
// Validate the form.
func (f Settings) Validate() error {
if len(f.Title) == 0 {
return errors.New("website title is required")
}
if f.AdminEmail != "" {
_, err := mail.ParseAddress(f.AdminEmail)
if err != nil {
return err
}
}
return nil
}