Don't swallow validation errors.
Refs
@@ -8,11 +8,19 @@ import (
// Validate returns an error if the CheckName and Subscription fields are not
// provided.
func (s *Silenced) Validate() error {
- checkNameErr := ValidateName(s.Check)
- subscriptionErr := ValidateName(s.Subscription)
- if checkNameErr != nil && subscriptionErr != nil {
+ if s.Subscription == "" && s.Check == "" {
return errors.New("must provide check or subscription")
}
+ if s.Subscription != "" {
+ if err := ValidateName(s.Subscription); err != nil {
+ return err
+ }
+ }
+ if s.Check != "" {
+ if err := ValidateName(s.Check); err != nil {
+ return err
+ }
+ }
return nil
}
