// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: internal/module/reverse_tunnel/rpc/rpc.proto

package rpc

import (
	"bytes"
	"errors"
	"fmt"
	"net"
	"net/mail"
	"net/url"
	"regexp"
	"sort"
	"strings"
	"time"
	"unicode/utf8"

	"google.golang.org/protobuf/types/known/anypb"
)

// ensure the imports are used
var (
	_ = bytes.MinRead
	_ = errors.New("")
	_ = fmt.Print
	_ = utf8.UTFMax
	_ = (*regexp.Regexp)(nil)
	_ = (*strings.Reader)(nil)
	_ = net.IPv4len
	_ = time.Duration(0)
	_ = (*url.URL)(nil)
	_ = (*mail.Address)(nil)
	_ = anypb.Any{}
	_ = sort.Sort
)

// Validate checks the field values on Descriptor with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Descriptor) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Descriptor with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in DescriptorMultiError, or
// nil if none found.
func (m *Descriptor) ValidateAll() error {
	return m.validate(true)
}

func (m *Descriptor) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	if m.GetAgentDescriptor() == nil {
		err := DescriptorValidationError{
			field:  "AgentDescriptor",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if all {
		switch v := interface{}(m.GetAgentDescriptor()).(type) {
		case interface{ ValidateAll() error }:
			if err := v.ValidateAll(); err != nil {
				errors = append(errors, DescriptorValidationError{
					field:  "AgentDescriptor",
					reason: "embedded message failed validation",
					cause:  err,
				})
			}
		case interface{ Validate() error }:
			if err := v.Validate(); err != nil {
				errors = append(errors, DescriptorValidationError{
					field:  "AgentDescriptor",
					reason: "embedded message failed validation",
					cause:  err,
				})
			}
		}
	} else if v, ok := interface{}(m.GetAgentDescriptor()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return DescriptorValidationError{
				field:  "AgentDescriptor",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if len(errors) > 0 {
		return DescriptorMultiError(errors)
	}

	return nil
}

// DescriptorMultiError is an error wrapping multiple validation errors
// returned by Descriptor.ValidateAll() if the designated constraints aren't met.
type DescriptorMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m DescriptorMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m DescriptorMultiError) AllErrors() []error { return m }

// DescriptorValidationError is the validation error returned by
// Descriptor.Validate if the designated constraints aren't met.
type DescriptorValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e DescriptorValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e DescriptorValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e DescriptorValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e DescriptorValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e DescriptorValidationError) ErrorName() string { return "DescriptorValidationError" }

// Error satisfies the builtin error interface
func (e DescriptorValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sDescriptor.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = DescriptorValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = DescriptorValidationError{}

// Validate checks the field values on Header with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Header) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Header with the rules defined in the
// proto definition for this message. If any rules are violated, the result is
// a list of violation errors wrapped in HeaderMultiError, or nil if none found.
func (m *Header) ValidateAll() error {
	return m.validate(true)
}

func (m *Header) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	{
		sorted_keys := make([]string, len(m.GetMeta()))
		i := 0
		for key := range m.GetMeta() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetMeta()[key]
			_ = val

			// no validation rules for Meta[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, HeaderValidationError{
							field:  fmt.Sprintf("Meta[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, HeaderValidationError{
							field:  fmt.Sprintf("Meta[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return HeaderValidationError{
						field:  fmt.Sprintf("Meta[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	if len(errors) > 0 {
		return HeaderMultiError(errors)
	}

	return nil
}

// HeaderMultiError is an error wrapping multiple validation errors returned by
// Header.ValidateAll() if the designated constraints aren't met.
type HeaderMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m HeaderMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m HeaderMultiError) AllErrors() []error { return m }

// HeaderValidationError is the validation error returned by Header.Validate if
// the designated constraints aren't met.
type HeaderValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e HeaderValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e HeaderValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e HeaderValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e HeaderValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e HeaderValidationError) ErrorName() string { return "HeaderValidationError" }

// Error satisfies the builtin error interface
func (e HeaderValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sHeader.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = HeaderValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = HeaderValidationError{}

// Validate checks the field values on Message with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Message) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Message with the rules defined in the
// proto definition for this message. If any rules are violated, the result is
// a list of violation errors wrapped in MessageMultiError, or nil if none found.
func (m *Message) ValidateAll() error {
	return m.validate(true)
}

func (m *Message) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for Data

	if len(errors) > 0 {
		return MessageMultiError(errors)
	}

	return nil
}

// MessageMultiError is an error wrapping multiple validation errors returned
// by Message.ValidateAll() if the designated constraints aren't met.
type MessageMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m MessageMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m MessageMultiError) AllErrors() []error { return m }

// MessageValidationError is the validation error returned by Message.Validate
// if the designated constraints aren't met.
type MessageValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e MessageValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e MessageValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e MessageValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e MessageValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e MessageValidationError) ErrorName() string { return "MessageValidationError" }

// Error satisfies the builtin error interface
func (e MessageValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sMessage.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = MessageValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = MessageValidationError{}

// Validate checks the field values on Trailer with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Trailer) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Trailer with the rules defined in the
// proto definition for this message. If any rules are violated, the result is
// a list of violation errors wrapped in TrailerMultiError, or nil if none found.
func (m *Trailer) ValidateAll() error {
	return m.validate(true)
}

func (m *Trailer) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	{
		sorted_keys := make([]string, len(m.GetMeta()))
		i := 0
		for key := range m.GetMeta() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetMeta()[key]
			_ = val

			// no validation rules for Meta[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, TrailerValidationError{
							field:  fmt.Sprintf("Meta[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, TrailerValidationError{
							field:  fmt.Sprintf("Meta[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return TrailerValidationError{
						field:  fmt.Sprintf("Meta[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	if len(errors) > 0 {
		return TrailerMultiError(errors)
	}

	return nil
}

// TrailerMultiError is an error wrapping multiple validation errors returned
// by Trailer.ValidateAll() if the designated constraints aren't met.
type TrailerMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m TrailerMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m TrailerMultiError) AllErrors() []error { return m }

// TrailerValidationError is the validation error returned by Trailer.Validate
// if the designated constraints aren't met.
type TrailerValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e TrailerValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e TrailerValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e TrailerValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e TrailerValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e TrailerValidationError) ErrorName() string { return "TrailerValidationError" }

// Error satisfies the builtin error interface
func (e TrailerValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sTrailer.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = TrailerValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = TrailerValidationError{}

// Validate checks the field values on Error with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Error) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Error with the rules defined in the
// proto definition for this message. If any rules are violated, the result is
// a list of violation errors wrapped in ErrorMultiError, or nil if none found.
func (m *Error) ValidateAll() error {
	return m.validate(true)
}

func (m *Error) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	if m.GetStatus() == nil {
		err := ErrorValidationError{
			field:  "Status",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if all {
		switch v := interface{}(m.GetStatus()).(type) {
		case interface{ ValidateAll() error }:
			if err := v.ValidateAll(); err != nil {
				errors = append(errors, ErrorValidationError{
					field:  "Status",
					reason: "embedded message failed validation",
					cause:  err,
				})
			}
		case interface{ Validate() error }:
			if err := v.Validate(); err != nil {
				errors = append(errors, ErrorValidationError{
					field:  "Status",
					reason: "embedded message failed validation",
					cause:  err,
				})
			}
		}
	} else if v, ok := interface{}(m.GetStatus()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ErrorValidationError{
				field:  "Status",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if len(errors) > 0 {
		return ErrorMultiError(errors)
	}

	return nil
}

// ErrorMultiError is an error wrapping multiple validation errors returned by
// Error.ValidateAll() if the designated constraints aren't met.
type ErrorMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m ErrorMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ErrorMultiError) AllErrors() []error { return m }

// ErrorValidationError is the validation error returned by Error.Validate if
// the designated constraints aren't met.
type ErrorValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e ErrorValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e ErrorValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e ErrorValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e ErrorValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e ErrorValidationError) ErrorName() string { return "ErrorValidationError" }

// Error satisfies the builtin error interface
func (e ErrorValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sError.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ErrorValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ErrorValidationError{}

// Validate checks the field values on ConnectRequest with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *ConnectRequest) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ConnectRequest with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in ConnectRequestMultiError,
// or nil if none found.
func (m *ConnectRequest) ValidateAll() error {
	return m.validate(true)
}

func (m *ConnectRequest) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	oneofMsgPresent := false
	switch v := m.Msg.(type) {
	case *ConnectRequest_Descriptor_:
		if v == nil {
			err := ConnectRequestValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetDescriptor_() == nil {
			err := ConnectRequestValidationError{
				field:  "Descriptor_",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetDescriptor_()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Descriptor_",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Descriptor_",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetDescriptor_()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectRequestValidationError{
					field:  "Descriptor_",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *ConnectRequest_Header:
		if v == nil {
			err := ConnectRequestValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetHeader() == nil {
			err := ConnectRequestValidationError{
				field:  "Header",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetHeader()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Header",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Header",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectRequestValidationError{
					field:  "Header",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *ConnectRequest_Message:
		if v == nil {
			err := ConnectRequestValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetMessage() == nil {
			err := ConnectRequestValidationError{
				field:  "Message",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetMessage()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Message",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Message",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetMessage()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectRequestValidationError{
					field:  "Message",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *ConnectRequest_Trailer:
		if v == nil {
			err := ConnectRequestValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetTrailer() == nil {
			err := ConnectRequestValidationError{
				field:  "Trailer",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetTrailer()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Trailer",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Trailer",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetTrailer()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectRequestValidationError{
					field:  "Trailer",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *ConnectRequest_Error:
		if v == nil {
			err := ConnectRequestValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetError() == nil {
			err := ConnectRequestValidationError{
				field:  "Error",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetError()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Error",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectRequestValidationError{
						field:  "Error",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetError()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectRequestValidationError{
					field:  "Error",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	default:
		_ = v // ensures v is used
	}
	if !oneofMsgPresent {
		err := ConnectRequestValidationError{
			field:  "Msg",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if len(errors) > 0 {
		return ConnectRequestMultiError(errors)
	}

	return nil
}

// ConnectRequestMultiError is an error wrapping multiple validation errors
// returned by ConnectRequest.ValidateAll() if the designated constraints
// aren't met.
type ConnectRequestMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m ConnectRequestMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ConnectRequestMultiError) AllErrors() []error { return m }

// ConnectRequestValidationError is the validation error returned by
// ConnectRequest.Validate if the designated constraints aren't met.
type ConnectRequestValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e ConnectRequestValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e ConnectRequestValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e ConnectRequestValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e ConnectRequestValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e ConnectRequestValidationError) ErrorName() string { return "ConnectRequestValidationError" }

// Error satisfies the builtin error interface
func (e ConnectRequestValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConnectRequest.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ConnectRequestValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ConnectRequestValidationError{}

// Validate checks the field values on RequestInfo with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *RequestInfo) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on RequestInfo with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in RequestInfoMultiError, or
// nil if none found.
func (m *RequestInfo) ValidateAll() error {
	return m.validate(true)
}

func (m *RequestInfo) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for MethodName

	{
		sorted_keys := make([]string, len(m.GetMeta()))
		i := 0
		for key := range m.GetMeta() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetMeta()[key]
			_ = val

			// no validation rules for Meta[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, RequestInfoValidationError{
							field:  fmt.Sprintf("Meta[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, RequestInfoValidationError{
							field:  fmt.Sprintf("Meta[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return RequestInfoValidationError{
						field:  fmt.Sprintf("Meta[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	if len(errors) > 0 {
		return RequestInfoMultiError(errors)
	}

	return nil
}

// RequestInfoMultiError is an error wrapping multiple validation errors
// returned by RequestInfo.ValidateAll() if the designated constraints aren't met.
type RequestInfoMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m RequestInfoMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m RequestInfoMultiError) AllErrors() []error { return m }

// RequestInfoValidationError is the validation error returned by
// RequestInfo.Validate if the designated constraints aren't met.
type RequestInfoValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e RequestInfoValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e RequestInfoValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e RequestInfoValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e RequestInfoValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e RequestInfoValidationError) ErrorName() string { return "RequestInfoValidationError" }

// Error satisfies the builtin error interface
func (e RequestInfoValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sRequestInfo.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = RequestInfoValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = RequestInfoValidationError{}

// Validate checks the field values on CloseSend with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *CloseSend) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on CloseSend with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in CloseSendMultiError, or nil
// if none found.
func (m *CloseSend) ValidateAll() error {
	return m.validate(true)
}

func (m *CloseSend) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	if len(errors) > 0 {
		return CloseSendMultiError(errors)
	}

	return nil
}

// CloseSendMultiError is an error wrapping multiple validation errors returned
// by CloseSend.ValidateAll() if the designated constraints aren't met.
type CloseSendMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m CloseSendMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m CloseSendMultiError) AllErrors() []error { return m }

// CloseSendValidationError is the validation error returned by
// CloseSend.Validate if the designated constraints aren't met.
type CloseSendValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e CloseSendValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e CloseSendValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e CloseSendValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e CloseSendValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e CloseSendValidationError) ErrorName() string { return "CloseSendValidationError" }

// Error satisfies the builtin error interface
func (e CloseSendValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sCloseSend.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = CloseSendValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = CloseSendValidationError{}

// Validate checks the field values on ConnectResponse with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
func (m *ConnectResponse) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ConnectResponse with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// ConnectResponseMultiError, or nil if none found.
func (m *ConnectResponse) ValidateAll() error {
	return m.validate(true)
}

func (m *ConnectResponse) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	oneofMsgPresent := false
	switch v := m.Msg.(type) {
	case *ConnectResponse_RequestInfo:
		if v == nil {
			err := ConnectResponseValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetRequestInfo() == nil {
			err := ConnectResponseValidationError{
				field:  "RequestInfo",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetRequestInfo()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectResponseValidationError{
						field:  "RequestInfo",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectResponseValidationError{
						field:  "RequestInfo",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetRequestInfo()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectResponseValidationError{
					field:  "RequestInfo",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *ConnectResponse_Message:
		if v == nil {
			err := ConnectResponseValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetMessage() == nil {
			err := ConnectResponseValidationError{
				field:  "Message",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetMessage()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectResponseValidationError{
						field:  "Message",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectResponseValidationError{
						field:  "Message",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetMessage()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectResponseValidationError{
					field:  "Message",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *ConnectResponse_CloseSend:
		if v == nil {
			err := ConnectResponseValidationError{
				field:  "Msg",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofMsgPresent = true

		if m.GetCloseSend() == nil {
			err := ConnectResponseValidationError{
				field:  "CloseSend",
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetCloseSend()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConnectResponseValidationError{
						field:  "CloseSend",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConnectResponseValidationError{
						field:  "CloseSend",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetCloseSend()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConnectResponseValidationError{
					field:  "CloseSend",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	default:
		_ = v // ensures v is used
	}
	if !oneofMsgPresent {
		err := ConnectResponseValidationError{
			field:  "Msg",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if len(errors) > 0 {
		return ConnectResponseMultiError(errors)
	}

	return nil
}

// ConnectResponseMultiError is an error wrapping multiple validation errors
// returned by ConnectResponse.ValidateAll() if the designated constraints
// aren't met.
type ConnectResponseMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m ConnectResponseMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ConnectResponseMultiError) AllErrors() []error { return m }

// ConnectResponseValidationError is the validation error returned by
// ConnectResponse.Validate if the designated constraints aren't met.
type ConnectResponseValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e ConnectResponseValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e ConnectResponseValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e ConnectResponseValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e ConnectResponseValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e ConnectResponseValidationError) ErrorName() string { return "ConnectResponseValidationError" }

// Error satisfies the builtin error interface
func (e ConnectResponseValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConnectResponse.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ConnectResponseValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ConnectResponseValidationError{}
