From 1348f8f5fcaa1c29550d7c03a641a25259c59b14 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 7 Mar 2014 12:10:40 -0700 Subject: [PATCH] added validations for settings screen --- pkg/model/settings.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/model/settings.go b/pkg/model/settings.go index e794fbd9e..978b289fe 100644 --- a/pkg/model/settings.go +++ b/pkg/model/settings.go @@ -8,6 +8,8 @@ import ( var ( ErrInvalidGitHubTrailingSlash = errors.New("GitHub URL should not have a trailing slash") + ErrInvalidSmtpAddress = errors.New("SMTP From Address must be provided") + ErrInvalidSmtpPort = errors.New("SMTP Port must be provided") ) type Settings struct { @@ -50,6 +52,10 @@ func (s *Settings) Validate() error { switch { case strings.HasSuffix(s.GitHubApiUrl, "/"): return ErrInvalidGitHubTrailingSlash + case len(s.SmtpServer) != 0 && len(s.SmtpPort) == 0: + return ErrInvalidSmtpPort + case len(s.SmtpServer) != 0 && len(s.SmtpAddress) == 0: + return ErrInvalidSmtpAddress default: return nil }