func (p PortRange) Validate() error {
	proto := strings.ToLower(p.Protocol)
	if proto != "tcp" && proto != "udp" && proto != "icmp" {
		return errors.Errorf(`invalid protocol %q, expected "tcp", "udp", or "icmp"`, proto)
	}
	if proto == "icmp" {
		if p.FromPort == p.ToPort && p.FromPort == -1 {
			return nil
		}
		return errors.Errorf(`protocol "icmp" doesn't support any ports; got "%v"`, p.FromPort)
	}
	if p.FromPort > p.ToPort {
		return errors.Errorf("invalid port range %s", p)
	} else if p.FromPort <= 0 || p.FromPort > 65535 || p.ToPort <= 0 || p.ToPort > 65535 {
		return errors.Errorf("port range bounds must be between 1 and 65535, got %d-%d", p.FromPort, p.ToPort)
	}
	return nil
}
// IsValid determines if the port range is valid.
IsValid determines if the port range is valid.
// IsValid determines if the port range is valid .
func (p PortRange) Validate() error {
	proto := strings.ToLower(p.Protocol)
	if proto != "tcp" && proto != "udp" && proto != "icmp" {
		return errors.Errorf(`invalid protocol %q, expected "tcp", "udp", or "icmp"`, proto)
	}
	if proto == "icmp" {
		if p.FromPort == p.ToPort && p.FromPort == -1 {
			return nil
		}
		return errors.Errorf(`protocol "icmp" doesn't support any ports; got "%v"`, p.FromPort)
	}
	if p.FromPort > p.ToPort {
		return errors.Errorf("invalid port range %s", p)
	} else if p.FromPort <= 0 || p.FromPort > 65535 || p.ToPort <= 0 || p.ToPort > 65535 {
		return errors.Errorf("port range bounds must be between 1 and 65535, got %d-%d", p.FromPort, p.ToPort)
	}
	return nil
}
func ( p PortRange ) Validate ( ) error { proto := strings . ToLower ( p . Protocol ) if proto != " " && proto != " " && proto != " " { return errors . Errorf ( `invalid protocol %q, expected "tcp", "udp", or "icmp"` , proto ) } if proto == " " { if p . FromPort == p . ToPort && p . FromPort == - 1 { return nil } return errors . Errorf ( `protocol "icmp" doesn't support any ports; got "%v"` , p . FromPort ) } if p . FromPort > p . ToPort { return errors . Errorf ( " " , p ) } else if p . FromPort <= 0 || p . FromPort > 65535 || p . ToPort <= 0 || p . ToPort > 65535 { return errors . Errorf ( " " , p . FromPort , p . ToPort ) } return nil }
IsValid determines if the port range is valid.
IsValid determines if the port range is valid .