blog/core/internal/forms/settings.go

40 lines
682 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
2018-02-02 04:14:42 +00:00
Description string
2017-11-20 05:49:19 +00:00
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
}