mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-10 17:45:36 +00:00
added validations for settings screen
This commit is contained in:
parent
68ff4aa2d1
commit
1348f8f5fc
1 changed files with 6 additions and 0 deletions
|
@ -8,6 +8,8 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrInvalidGitHubTrailingSlash = errors.New("GitHub URL should not have a trailing slash")
|
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 {
|
type Settings struct {
|
||||||
|
@ -50,6 +52,10 @@ func (s *Settings) Validate() error {
|
||||||
switch {
|
switch {
|
||||||
case strings.HasSuffix(s.GitHubApiUrl, "/"):
|
case strings.HasSuffix(s.GitHubApiUrl, "/"):
|
||||||
return ErrInvalidGitHubTrailingSlash
|
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:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue