// Code generated by protoc-gen-validate
// source: envoy/service/ratelimit/v2/rls.proto
// DO NOT EDIT!!!

package v2

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

	"github.com/gogo/protobuf/types"
)

// 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)
	_ = types.DynamicAny{}
)

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

	// no validation rules for Domain

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

		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return RateLimitRequestValidationError{
					Field:  fmt.Sprintf("Descriptors[%v]", idx),
					Reason: "embedded message failed validation",
					Cause:  err,
				}
			}
		}

	}

	// no validation rules for HitsAddend

	return nil
}

// RateLimitRequestValidationError is the validation error returned by
// RateLimitRequest.Validate if the designated constraints aren't met.
type RateLimitRequestValidationError struct {
	Field  string
	Reason string
	Cause  error
	Key    bool
}

// Error satisfies the builtin error interface
func (e RateLimitRequestValidationError) 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 %sRateLimitRequest.%s: %s%s",
		key,
		e.Field,
		e.Reason,
		cause)
}

var _ error = RateLimitRequestValidationError{}

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

	// no validation rules for OverallCode

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

		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return RateLimitResponseValidationError{
					Field:  fmt.Sprintf("Statuses[%v]", idx),
					Reason: "embedded message failed validation",
					Cause:  err,
				}
			}
		}

	}

	return nil
}

// RateLimitResponseValidationError is the validation error returned by
// RateLimitResponse.Validate if the designated constraints aren't met.
type RateLimitResponseValidationError struct {
	Field  string
	Reason string
	Cause  error
	Key    bool
}

// Error satisfies the builtin error interface
func (e RateLimitResponseValidationError) 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 %sRateLimitResponse.%s: %s%s",
		key,
		e.Field,
		e.Reason,
		cause)
}

var _ error = RateLimitResponseValidationError{}

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

	// no validation rules for RequestsPerUnit

	// no validation rules for Unit

	return nil
}

// RateLimitResponse_RateLimitValidationError is the validation error returned
// by RateLimitResponse_RateLimit.Validate if the designated constraints
// aren't met.
type RateLimitResponse_RateLimitValidationError struct {
	Field  string
	Reason string
	Cause  error
	Key    bool
}

// Error satisfies the builtin error interface
func (e RateLimitResponse_RateLimitValidationError) 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 %sRateLimitResponse_RateLimit.%s: %s%s",
		key,
		e.Field,
		e.Reason,
		cause)
}

var _ error = RateLimitResponse_RateLimitValidationError{}

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

	// no validation rules for Code

	if v, ok := interface{}(m.GetCurrentLimit()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return RateLimitResponse_DescriptorStatusValidationError{
				Field:  "CurrentLimit",
				Reason: "embedded message failed validation",
				Cause:  err,
			}
		}
	}

	// no validation rules for LimitRemaining

	return nil
}

// RateLimitResponse_DescriptorStatusValidationError is the validation error
// returned by RateLimitResponse_DescriptorStatus.Validate if the designated
// constraints aren't met.
type RateLimitResponse_DescriptorStatusValidationError struct {
	Field  string
	Reason string
	Cause  error
	Key    bool
}

// Error satisfies the builtin error interface
func (e RateLimitResponse_DescriptorStatusValidationError) 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 %sRateLimitResponse_DescriptorStatus.%s: %s%s",
		key,
		e.Field,
		e.Reason,
		cause)
}

var _ error = RateLimitResponse_DescriptorStatusValidationError{}
