// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: internal/module/configuration_project/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 ListAgentConfigFilesRequest 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 *ListAgentConfigFilesRequest) Validate() error {
	return m.validate(false)
}

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

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

	var errors []error

	if m.GetRepository() == nil {
		err := ListAgentConfigFilesRequestValidationError{
			field:  "Repository",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	if m.GetGitalyAddress() == nil {
		err := ListAgentConfigFilesRequestValidationError{
			field:  "GitalyAddress",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	// no validation rules for DefaultBranch

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m ListAgentConfigFilesRequestMultiError) 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 ListAgentConfigFilesRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = ListAgentConfigFilesRequestValidationError{}

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

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

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

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

	var errors []error

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

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ListAgentConfigFilesResponseValidationError{
						field:  fmt.Sprintf("ConfigFiles[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ListAgentConfigFilesResponseValidationError{
						field:  fmt.Sprintf("ConfigFiles[%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 ListAgentConfigFilesResponseValidationError{
					field:  fmt.Sprintf("ConfigFiles[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m ListAgentConfigFilesResponseMultiError) 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 ListAgentConfigFilesResponseMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = ListAgentConfigFilesResponseValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Name

	// no validation rules for AgentName

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m AgentConfigFileMultiError) 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 AgentConfigFileMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = AgentConfigFileValidationError{}

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