Debian Codegraph @

envoy/config/ratelimit/v3/rls.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/ratelimit/v3/rls.proto
4
5 package ratelimitv3
6
7 import (
8 "bytes"
9 "errors"
10 "fmt"
11 "net"
12 "net/mail"
13 "net/url"
14 "regexp"
15 "sort"
16 "strings"
17 "time"
18 "unicode/utf8"
19
20 "google.golang.org/protobuf/types/known/anypb"
21
22 v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
23 )
24
25 // ensure the imports are used
26 var (
27 _ = bytes.MinRead
28 _ = errors.New("")
29 _ = fmt.Print
30 _ = utf8.UTFMax
31 _ = (*regexp.Regexp)(nil)
32 _ = (*strings.Reader)(nil)
33 _ = net.IPv4len
34 _ = time.Duration(0)
35 _ = (*url.URL)(nil)
36 _ = (*mail.Address)(nil)
37 _ = anypb.Any{}
38 _ = sort.Sort
39
40 _ = v3.ApiVersion(0)
41 )
42
43 // Validate checks the field values on RateLimitServiceConfig with the rules
44 // defined in the proto definition for this message. If any rules are
45 // violated, the first error encountered is returned, or nil if there are no violations.
46 func (m *RateLimitServiceConfig) Validate() error {
47 return m.validate(false)
48 }
49
50 // ValidateAll checks the field values on RateLimitServiceConfig with the rules
51 // defined in the proto definition for this message. If any rules are
52 // violated, the result is a list of violation errors wrapped in
53 // RateLimitServiceConfigMultiError, or nil if none found.
54 func (m *RateLimitServiceConfig) ValidateAll() error {
55 return m.validate(true)
56 }
57
58 func (m *RateLimitServiceConfig) validate(all bool) error {
59 if m == nil {
60 return nil
61 }
62
63 var errors []error
64
65 if m.GetGrpcService() == nil {
66 err := RateLimitServiceConfigValidationError{
67 field: "GrpcService",
68 reason: "value is required",
69 }
70 if !all {
71 return err
72 }
73 errors = append(errors, err)
74 }
75
76 if all {
77 switch v := interface{}(m.GetGrpcService()).(type) {
78 case interface{ ValidateAll() error }:
79 if err := v.ValidateAll(); err != nil {
80 errors = append(errors, RateLimitServiceConfigValidationError{
81 field: "GrpcService",
82 reason: "embedded message failed validation",
83 cause: err,
84 })
85 }
86 case interface{ Validate() error }:
87 if err := v.Validate(); err != nil {
88 errors = append(errors, RateLimitServiceConfigValidationError{
89 field: "GrpcService",
90 reason: "embedded message failed validation",
91 cause: err,
92 })
93 }
94 }
95 } else if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
96 if err := v.Validate(); err != nil {
97 return RateLimitServiceConfigValidationError{
98 field: "GrpcService",
99 reason: "embedded message failed validation",
100 cause: err,
101 }
102 }
103 }
104
105 if _, ok := v3.ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
106 err := RateLimitServiceConfigValidationError{
107 field: "TransportApiVersion",
108 reason: "value must be one of the defined enum values",
109 }
110 if !all {
111 return err
112 }
113 errors = append(errors, err)
114 }
115
116 if len(errors) > 0 {
117 return RateLimitServiceConfigMultiError(errors)
118 }
119
120 return nil
121 }
122
123 // RateLimitServiceConfigMultiError is an error wrapping multiple validation
124 // errors returned by RateLimitServiceConfig.ValidateAll() if the designated
125 // constraints aren't met.
126 type RateLimitServiceConfigMultiError []error
127
128 // Error returns a concatenation of all the error messages it wraps.
129 func (m RateLimitServiceConfigMultiError) Error() string {
130 var msgs []string
131 for _, err := range m {
132 msgs = append(msgs, err.Error())
133 }
134 return strings.Join(msgs, "; ")
135 }
136
137 // AllErrors returns a list of validation violation errors.
138 func (m RateLimitServiceConfigMultiError) AllErrors() []error { return m }
139
140 // RateLimitServiceConfigValidationError is the validation error returned by
141 // RateLimitServiceConfig.Validate if the designated constraints aren't met.
142 type RateLimitServiceConfigValidationError struct {
143 field string
144 reason string
145 cause error
146 key bool
147 }
148
149 // Field function returns field value.
150 func (e RateLimitServiceConfigValidationError) Field() string { return e.field }
151
152 // Reason function returns reason value.
153 func (e RateLimitServiceConfigValidationError) Reason() string { return e.reason }
154
155 // Cause function returns cause value.
156 func (e RateLimitServiceConfigValidationError) Cause() error { return e.cause }
157
158 // Key function returns key value.
159 func (e RateLimitServiceConfigValidationError) Key() bool { return e.key }
160
161 // ErrorName returns error name.
162 func (e RateLimitServiceConfigValidationError) ErrorName() string {
163 return "RateLimitServiceConfigValidationError"
164 }
165
166 // Error satisfies the builtin error interface
167 func (e RateLimitServiceConfigValidationError) Error() string {
168 cause := ""
169 if e.cause != nil {
170 cause = fmt.Sprintf(" | caused by: %v", e.cause)
171 }
172
173 key := ""
174 if e.key {
175 key = "key for "
176 }
177
178 return fmt.Sprintf(
179 "invalid %sRateLimitServiceConfig.%s: %s%s",
180 key,
181 e.field,
182 e.reason,
183 cause)
184 }
185
186 var _ error = RateLimitServiceConfigValidationError{}
187
188 var _ interface {
189 Field() string
190 Reason() string
191 Key() bool
192 Cause() error
193 ErrorName() string
194 } = RateLimitServiceConfigValidationError{}