Exemple #1
1
// Validate performs validation on the trap and returns any errors
func (trap *TCPTrap) Validate() []error {
	var errors []error

	errors = trap.baseTrap.Validate()

	err := validate.Port(trap.params["port"])
	if err != nil {
		errors = append(errors, fmt.Errorf("Invalid port: %s", err))
	}

	err = validate.Host(trap.params["host"])
	if err != nil {
		errors = append(errors, fmt.Errorf("Invalid host: %s", err))
	}

	return errors
}
Exemple #2
0
// Validate performs validation on the trap and returns any errors
func (sh *SyslogHandler) Validate() []error {
	var errors []error

	errors = sh.baseHandler.Validate()

	if portParam, ok := sh.params["port"]; ok {
		err := validate.Port(portParam)
		if err != nil {
			errors = append(errors, fmt.Errorf("Invalid port: %s", err))
		}
	}

	if hostParam, ok := sh.params["host"]; ok {
		err := validate.Host(hostParam)
		if err != nil {
			errors = append(errors, fmt.Errorf("Invalid host: %s", err))
		}
	}

	return errors
}