//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 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 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 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.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,
			}
		}
	}

	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 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 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{}
