//go:build !disable_pgv
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: envoy/extensions/filters/http/mcp_json_rest_bridge/v3/mcp_json_rest_bridge.proto

package mcp_json_rest_bridgev3

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 McpJsonRestBridge 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 *McpJsonRestBridge) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on McpJsonRestBridge 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
// McpJsonRestBridgeMultiError, or nil if none found.
func (m *McpJsonRestBridge) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

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

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

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

	if _, ok := McpJsonRestBridge_RequestStorageMode_name[int32(m.GetRequestStorageMode())]; !ok {
		err := McpJsonRestBridgeValidationError{
			field:  "RequestStorageMode",
			reason: "value must be one of the defined enum values",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	// no validation rules for DisableClearRouteCache

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e McpJsonRestBridgeValidationError) 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 %sMcpJsonRestBridge.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = McpJsonRestBridgeValidationError{}

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

// Validate checks the field values on TraceContextExtractionOptions 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 *TraceContextExtractionOptions) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on TraceContextExtractionOptions 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
// TraceContextExtractionOptionsMultiError, or nil if none found.
func (m *TraceContextExtractionOptions) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e TraceContextExtractionOptionsValidationError) 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 %sTraceContextExtractionOptions.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = TraceContextExtractionOptionsValidationError{}

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

// Validate checks the field values on ServerInfo 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 *ServerInfo) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ServerInfo 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 ServerInfoMultiError, or
// nil if none found.
func (m *ServerInfo) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

	// no validation rules for Description

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e ServerInfoValidationError) 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 %sServerInfo.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ServerInfoValidationError{}

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

// Validate checks the field values on ToolsListLocal 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 *ToolsListLocal) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ToolsListLocal 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 ToolsListLocalMultiError,
// or nil if none found.
func (m *ToolsListLocal) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e ToolsListLocalValidationError) 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 %sToolsListLocal.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ToolsListLocalValidationError{}

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

// Validate checks the field values on ServerToolConfig 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 *ServerToolConfig) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ServerToolConfig 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
// ServerToolConfigMultiError, or nil if none found.
func (m *ServerToolConfig) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

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

	}

	// no validation rules for ListChanged

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

	switch v := m.ToolListConfig.(type) {
	case *ServerToolConfig_ToolListHttpRule:
		if v == nil {
			err := ServerToolConfigValidationError{
				field:  "ToolListConfig",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

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

	case *ServerToolConfig_ToolListLocal:
		if v == nil {
			err := ServerToolConfigValidationError{
				field:  "ToolListConfig",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

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

	default:
		_ = v // ensures v is used
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e ServerToolConfigValidationError) 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 %sServerToolConfig.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ServerToolConfigValidationError{}

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

// Validate checks the field values on ToolsListSpecificConfig 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 *ToolsListSpecificConfig) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ToolsListSpecificConfig 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
// ToolsListSpecificConfigMultiError, or nil if none found.
func (m *ToolsListSpecificConfig) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

	// no validation rules for Title

	if utf8.RuneCountInString(m.GetDescription()) < 1 {
		err := ToolsListSpecificConfigValidationError{
			field:  "Description",
			reason: "value length must be at least 1 runes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	// no validation rules for InputSchema

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e ToolsListSpecificConfigValidationError) 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 %sToolsListSpecificConfig.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ToolsListSpecificConfigValidationError{}

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

// Validate checks the field values on McpServerInfo 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 *McpServerInfo) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on McpServerInfo 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 McpServerInfoMultiError, or
// nil if none found.
func (m *McpServerInfo) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

	// no validation rules for Path

	// no validation rules for Host

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e McpServerInfoValidationError) 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 %sMcpServerInfo.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = McpServerInfoValidationError{}

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

// Validate checks the field values on ToolConfig 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 *ToolConfig) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ToolConfig 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 ToolConfigMultiError, or
// nil if none found.
func (m *ToolConfig) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

	if utf8.RuneCountInString(m.GetName()) < 1 {
		err := ToolConfigValidationError{
			field:  "Name",
			reason: "value length must be at least 1 runes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

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

	// no validation rules for TextContentStreamingEnabled

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e ToolConfigValidationError) 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 %sToolConfig.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ToolConfigValidationError{}

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

// Validate checks the field values on HttpRule 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 *HttpRule) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on HttpRule 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 HttpRuleMultiError, or nil
// if none found.
func (m *HttpRule) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

	// no validation rules for Get

	// no validation rules for Put

	// no validation rules for Post

	// no validation rules for Delete

	// no validation rules for Patch

	// no validation rules for Body

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e HttpRuleValidationError) 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 %sHttpRule.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = HttpRuleValidationError{}

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

// Validate checks the field values on McpJsonRestBridgePerRoute 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 *McpJsonRestBridgePerRoute) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on McpJsonRestBridgePerRoute 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
// McpJsonRestBridgePerRouteMultiError, or nil if none found.
func (m *McpJsonRestBridgePerRoute) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e McpJsonRestBridgePerRouteValidationError) 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 %sMcpJsonRestBridgePerRoute.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = McpJsonRestBridgePerRouteValidationError{}

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