package alert

import (
	"fmt"
)

type CreateReq struct {
	Name     string `valid:"required"`
	Actions  []Action
	Triggers []Trigger
}

func (c *CreateReq) Validate() error {
	err := validateActions(c.Actions)
	if err != nil {
		return err
	}
	err = validateTriggers(c.Triggers)
	if err != nil {
		return err
	}
	return nil
}

func validateActions(actions []Action) error {
	if len(actions) == 0 {
		return fmt.Errorf("Actions: non-zero value required.")
	}
	return nil
}

func validateTriggers(triggers []Trigger) error {
	if len(triggers) == 0 {
		return fmt.Errorf("Triggers: non-zero value required.")
	}
	return nil
}

package alert

import (
	"fmt"
)

type CreateReq struct {
	Name     string `valid:"required"`
	Actions  []Action
	Triggers []Trigger
}

func (c *CreateReq) Validate() error {
	if len(c.Actions) == 0 {
		return fmt.Errorf("Actions: non-zero value required.")
	} else if len(c.Triggers) == 0 {
		return fmt.Errorf("Triggers: non-zero value required.")
	}
	return nil
}

--- 
+++ 
@@ -11,9 +11,26 @@
 }
 
 func (c *CreateReq) Validate() error {
-	if len(c.Actions) == 0 {
+	err := validateActions(c.Actions)
+	if err != nil {
+		return err
+	}
+	err = validateTriggers(c.Triggers)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func validateActions(actions []Action) error {
+	if len(actions) == 0 {
 		return fmt.Errorf("Actions: non-zero value required.")
-	} else if len(c.Triggers) == 0 {
+	}
+	return nil
+}
+
+func validateTriggers(triggers []Trigger) error {
+	if len(triggers) == 0 {
 		return fmt.Errorf("Triggers: non-zero value required.")
 	}
 	return nil
Move actions and triggers validation logic to the separate functions
