// Validate checks the field values on TcpProxy with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned.
541397
func (m *TcpProxy) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetStatPrefix()) < 1 {
		return TcpProxyValidationError{
			field:  "StatPrefix",
			reason: "value length must be at least 1 bytes",
		}
	}

	{
		tmp := m.GetMetadataMatch()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return TcpProxyValidationError{
					field:  "MetadataMatch",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	if d := m.GetIdleTimeout(); d != nil {
		dur := *d

		gt := time.Duration(0*time.Second + 0*time.Nanosecond)

		if dur <= gt {
			return TcpProxyValidationError{
				field:  "IdleTimeout",
				reason: "value must be greater than 0s",
			}
		}

	}

	{
		tmp := m.GetDownstreamIdleTimeout()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return TcpProxyValidationError{
					field:  "DownstreamIdleTimeout",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetUpstreamIdleTimeout()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return TcpProxyValidationError{
					field:  "UpstreamIdleTimeout",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	for idx, item := range m.GetAccessLog() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return TcpProxyValidationError{
						field:  fmt.Sprintf("AccessLog[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	{
		tmp := m.GetDeprecatedV1()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return TcpProxyValidationError{
					field:  "DeprecatedV1",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	if wrapper := m.GetMaxConnectAttempts(); wrapper != nil {

		if wrapper.GetValue() < 1 {
			return TcpProxyValidationError{
				field:  "MaxConnectAttempts",
				reason: "value must be greater than or equal to 1",
			}
		}

	}

	switch m.ClusterSpecifier.(type) {

	case *TcpProxy_Cluster:
		// no validation rules for Cluster

	case *TcpProxy_WeightedClusters:

		{
			tmp := m.GetWeightedClusters()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return TcpProxyValidationError{
						field:  "WeightedClusters",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	default:
		return TcpProxyValidationError{
			field:  "ClusterSpecifier",
			reason: "value is required",
		}

	}

	return nil
}
1179809
func (c *Config) Validate() error {
	if c.SocketName == "" {
		return errors.NotValidf("empty SocketName")
	}
	if c.PrometheusGatherer == nil {
		return errors.NotValidf("nil PrometheusGatherer")
	}
	return nil
}
621278
func (pTypeDef *StringTest) Validate() error {
	if pTypeDef.Name == "" {
		return fmt.Errorf("StringTest: Missing required field: name")
	}
	if pTypeDef.Parent == "" {
		return fmt.Errorf("StringTest: Missing required field: parent")
	}
	return nil
}
1231403
func (m *ThriftProxy) Validate() error {
	if m == nil {
		return nil
	}

	if _, ok := TransportType_name[int32(m.GetTransport())]; !ok {
		return ThriftProxyValidationError{
			field:  "Transport",
			reason: "value must be one of the defined enum values",
		}
	}

	if _, ok := ProtocolType_name[int32(m.GetProtocol())]; !ok {
		return ThriftProxyValidationError{
			field:  "Protocol",
			reason: "value must be one of the defined enum values",
		}
	}

	if len(m.GetStatPrefix()) < 1 {
		return ThriftProxyValidationError{
			field:  "StatPrefix",
			reason: "value length must be at least 1 bytes",
		}
	}

	{
		tmp := m.GetRouteConfig()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return ThriftProxyValidationError{
					field:  "RouteConfig",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	for idx, item := range m.GetThriftFilters() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return ThriftProxyValidationError{
						field:  fmt.Sprintf("ThriftFilters[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	return nil
}
1348953
func (m *TCPAccessLogEntry) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetCommonProperties()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return TCPAccessLogEntryValidationError{
					field:  "CommonProperties",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
995267
func (m *Router) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetDynamicStats()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouterValidationError{
					field:  "DynamicStats",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	// no validation rules for StartChildSpan

	for idx, item := range m.GetUpstreamLog() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouterValidationError{
						field:  fmt.Sprintf("UpstreamLog[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	// no validation rules for SuppressEnvoyHeaders

	return nil
}
1022045
func (m *ThriftProtocolOptions) Validate() error {
	if m == nil {
		return nil
	}

	if _, ok := TransportType_name[int32(m.GetTransport())]; !ok {
		return ThriftProtocolOptionsValidationError{
			field:  "Transport",
			reason: "value must be one of the defined enum values",
		}
	}

	if _, ok := ProtocolType_name[int32(m.GetProtocol())]; !ok {
		return ThriftProtocolOptionsValidationError{
			field:  "Protocol",
			reason: "value must be one of the defined enum values",
		}
	}

	return nil
}
497180
func (c *CheckType) Validate() error {
	intervalCheck := c.IsScript() || c.HTTP != "" || c.TCP != "" || c.GRPC != ""

	if c.Interval > 0 && c.TTL > 0 {
		return fmt.Errorf("Interval and TTL cannot both be specified")
	}
	if intervalCheck && c.Interval <= 0 {
		return fmt.Errorf("Interval must be > 0 for Script, HTTP, or TCP checks")
	}
	if intervalCheck && c.IsAlias() {
		return fmt.Errorf("Interval cannot be set for Alias checks")
	}
	if c.IsAlias() && c.TTL > 0 {
		return fmt.Errorf("TTL must be not be set for Alias checks")
	}
	if !intervalCheck && !c.IsAlias() && c.TTL <= 0 {
		return fmt.Errorf("TTL must be > 0 for TTL checks")
	}
	return nil
}
352648
func (m *MethodMatch_ParameterMatchSpecifier) Validate() error {
	if m == nil {
		return nil
	}

	switch m.ParameterMatchSpecifier.(type) {

	case *MethodMatch_ParameterMatchSpecifier_ExactMatch:
		// no validation rules for ExactMatch

	case *MethodMatch_ParameterMatchSpecifier_RangeMatch:

		{
			tmp := m.GetRangeMatch()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return MethodMatch_ParameterMatchSpecifierValidationError{
						field:  "RangeMatch",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	return nil
}
72162
func (m *SocketStreamedTraceSegment) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for TraceId

	switch m.MessagePiece.(type) {

	case *SocketStreamedTraceSegment_Connection:

		{
			tmp := m.GetConnection()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return SocketStreamedTraceSegmentValidationError{
						field:  "Connection",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *SocketStreamedTraceSegment_Event:

		{
			tmp := m.GetEvent()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return SocketStreamedTraceSegmentValidationError{
						field:  "Event",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	return nil
}
1080003
func (c *ConnectPacket) Validate() byte {
	if c.PasswordFlag && !c.UsernameFlag {
		return ErrRefusedBadUsernameOrPassword
	}
	if c.ReservedBit != 0 {
		//Bad reserved bit
		return ErrProtocolViolation
	}
	if (c.ProtocolName == "MQIsdp" && c.ProtocolVersion != 3) || (c.ProtocolName == "MQTT" && c.ProtocolVersion != 4) {
		//Mismatched or unsupported protocol version
		return ErrRefusedBadProtocolVersion
	}
	if c.ProtocolName != "MQIsdp" && c.ProtocolName != "MQTT" {
		//Bad protocol name
		return ErrProtocolViolation
	}
	if len(c.ClientIdentifier) > 65535 || len(c.Username) > 65535 || len(c.Password) > 65535 {
		//Bad size field
		return ErrProtocolViolation
	}
	if len(c.ClientIdentifier) == 0 && !c.CleanSession {
		//Bad client identifier
		return ErrRefusedIDRejected
	}
	return Accepted
}
472795
func (set *IPSet) Validate() bool {
	// Check if protocol is valid for `HashIPPort`, `HashIPPortIP` and `HashIPPortNet` type set.
	if set.SetType == HashIPPort || set.SetType == HashIPPortIP || set.SetType == HashIPPortNet {
		if valid := validateHashFamily(set.HashFamily); !valid {
			return false
		}
	}
	// check set type
	if valid := validateIPSetType(set.SetType); !valid {
		return false
	}
	// check port range for bitmap type set
	if set.SetType == BitmapPort {
		if valid := validatePortRange(set.PortRange); !valid {
			return false
		}
	}
	// check hash size value of ipset
	if set.HashSize <= 0 {
		klog.Errorf("Invalid hashsize value %d, should be >0", set.HashSize)
		return false
	}
	// check max elem value of ipset
	if set.MaxElem <= 0 {
		klog.Errorf("Invalid maxelem value %d, should be >0", set.MaxElem)
		return false
	}

	return true
}
1248901
func (p *Pushover) validate() error {
	// Check empty token
	if p.token == "" {
		return ErrEmptyToken
	}

	// Check invalid token
	if tokenRegexp.MatchString(p.token) == false {
		return ErrInvalidToken
	}
	return nil
}
429873
func (m *Http1ProtocolOptions) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetAllowAbsoluteUrl()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return Http1ProtocolOptionsValidationError{
					field:  "AllowAbsoluteUrl",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	// no validation rules for AcceptHttp_10

	// no validation rules for DefaultHostForHttp_10

	return nil
}
996822
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)
	}
	err := errors.Errorf(
		"invalid port range %d-%d/%s",
		p.FromPort,
		p.ToPort,
		p.Protocol,
	)
	switch {
	case p.FromPort > p.ToPort:
		return err
	case p.FromPort < 1 || p.FromPort > 65535:
		return err
	case p.ToPort < 1 || p.ToPort > 65535:
		return err
	}
	return nil
}
182811
func (val *Validation) Validate(checkers ...Checker) *Validation {

	for _, checker := range checkers {
		if pass, msg := checker(); !pass {
			if val == nil {
				val = &Validation{}
			}

			val.Errors = append(val.Errors, msg)
		}
	}

	return val
}
849694
func (i *I) Validate(ctx *Context) error {
	_, err := i.template(ctx)
	return err
}