1// Code generated by protoc-gen-validate. DO NOT EDIT. 2// source: envoy/type/matcher/metadata.proto 3 4package envoy_type_matcher 5 6import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "sort" 15 "strings" 16 "time" 17 "unicode/utf8" 18 19 "google.golang.org/protobuf/types/known/anypb" 20) 21 22// ensure the imports are used 23var ( 24 _ = bytes.MinRead 25 _ = errors.New("") 26 _ = fmt.Print 27 _ = utf8.UTFMax 28 _ = (*regexp.Regexp)(nil) 29 _ = (*strings.Reader)(nil) 30 _ = net.IPv4len 31 _ = time.Duration(0) 32 _ = (*url.URL)(nil) 33 _ = (*mail.Address)(nil) 34 _ = anypb.Any{} 35 _ = sort.Sort 36) 37 38// Validate checks the field values on MetadataMatcher with the rules defined 39// in the proto definition for this message. If any rules are violated, the 40// first error encountered is returned, or nil if there are no violations. 41func (m *MetadataMatcher) Validate() error { 42 return m.validate(false) 43} 44 45// ValidateAll checks the field values on MetadataMatcher with the rules 46// defined in the proto definition for this message. If any rules are 47// violated, the result is a list of violation errors wrapped in 48// MetadataMatcherMultiError, or nil if none found. 49func (m *MetadataMatcher) ValidateAll() error { 50 return m.validate(true) 51} 52 53func (m *MetadataMatcher) validate(all bool) error { 54 if m == nil { 55 return nil 56 } 57 58 var errors []error 59 60 if utf8.RuneCountInString(m.GetFilter()) < 1 { 61 err := MetadataMatcherValidationError{ 62 field: "Filter", 63 reason: "value length must be at least 1 runes", 64 } 65 if !all { 66 return err 67 } 68 errors = append(errors, err) 69 } 70 71 if len(m.GetPath()) < 1 { 72 err := MetadataMatcherValidationError{ 73 field: "Path", 74 reason: "value must contain at least 1 item(s)", 75 } 76 if !all { 77 return err 78 } 79 errors = append(errors, err) 80 } 81 82 for idx, item := range m.GetPath() { 83 _, _ = idx, item 84 85 if all { 86 switch v := interface{}(item).(type) { 87 case interface{ ValidateAll() error }: 88 if err := v.ValidateAll(); err != nil { 89 errors = append(errors, MetadataMatcherValidationError{ 90 field: fmt.Sprintf("Path[%v]", idx), 91 reason: "embedded message failed validation", 92 cause: err, 93 }) 94 } 95 case interface{ Validate() error }: 96 if err := v.Validate(); err != nil { 97 errors = append(errors, MetadataMatcherValidationError{ 98 field: fmt.Sprintf("Path[%v]", idx), 99 reason: "embedded message failed validation", 100 cause: err, 101 }) 102 } 103 } 104 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 105 if err := v.Validate(); err != nil { 106 return MetadataMatcherValidationError{ 107 field: fmt.Sprintf("Path[%v]", idx), 108 reason: "embedded message failed validation", 109 cause: err, 110 } 111 } 112 } 113 114 } 115 116 if m.GetValue() == nil { 117 err := MetadataMatcherValidationError{ 118 field: "Value", 119 reason: "value is required", 120 } 121 if !all { 122 return err 123 } 124 errors = append(errors, err) 125 } 126 127 if all { 128 switch v := interface{}(m.GetValue()).(type) { 129 case interface{ ValidateAll() error }: 130 if err := v.ValidateAll(); err != nil { 131 errors = append(errors, MetadataMatcherValidationError{ 132 field: "Value", 133 reason: "embedded message failed validation", 134 cause: err, 135 }) 136 } 137 case interface{ Validate() error }: 138 if err := v.Validate(); err != nil { 139 errors = append(errors, MetadataMatcherValidationError{ 140 field: "Value", 141 reason: "embedded message failed validation", 142 cause: err, 143 }) 144 } 145 } 146 } else if v, ok := interface{}(m.GetValue()).(interface{ Validate() error }); ok { 147 if err := v.Validate(); err != nil { 148 return MetadataMatcherValidationError{ 149 field: "Value", 150 reason: "embedded message failed validation", 151 cause: err, 152 } 153 } 154 } 155 156 if len(errors) > 0 { 157 return MetadataMatcherMultiError(errors) 158 } 159 return nil 160} 161 162// MetadataMatcherMultiError is an error wrapping multiple validation errors 163// returned by MetadataMatcher.ValidateAll() if the designated constraints 164// aren't met. 165type MetadataMatcherMultiError []error 166 167// Error returns a concatenation of all the error messages it wraps. 168func (m MetadataMatcherMultiError) Error() string { 169 var msgs []string 170 for _, err := range m { 171 msgs = append(msgs, err.Error()) 172 } 173 return strings.Join(msgs, "; ") 174} 175 176// AllErrors returns a list of validation violation errors. 177func (m MetadataMatcherMultiError) AllErrors() []error { return m } 178 179// MetadataMatcherValidationError is the validation error returned by 180// MetadataMatcher.Validate if the designated constraints aren't met. 181type MetadataMatcherValidationError struct { 182 field string 183 reason string 184 cause error 185 key bool 186} 187 188// Field function returns field value. 189func (e MetadataMatcherValidationError) Field() string { return e.field } 190 191// Reason function returns reason value. 192func (e MetadataMatcherValidationError) Reason() string { return e.reason } 193 194// Cause function returns cause value. 195func (e MetadataMatcherValidationError) Cause() error { return e.cause } 196 197// Key function returns key value. 198func (e MetadataMatcherValidationError) Key() bool { return e.key } 199 200// ErrorName returns error name. 201func (e MetadataMatcherValidationError) ErrorName() string { return "MetadataMatcherValidationError" } 202 203// Error satisfies the builtin error interface 204func (e MetadataMatcherValidationError) Error() string { 205 cause := "" 206 if e.cause != nil { 207 cause = fmt.Sprintf(" | caused by: %v", e.cause) 208 } 209 210 key := "" 211 if e.key { 212 key = "key for " 213 } 214 215 return fmt.Sprintf( 216 "invalid %sMetadataMatcher.%s: %s%s", 217 key, 218 e.field, 219 e.reason, 220 cause) 221} 222 223var _ error = MetadataMatcherValidationError{} 224 225var _ interface { 226 Field() string 227 Reason() string 228 Key() bool 229 Cause() error 230 ErrorName() string 231} = MetadataMatcherValidationError{} 232 233// Validate checks the field values on MetadataMatcher_PathSegment with the 234// rules defined in the proto definition for this message. If any rules are 235// violated, the first error encountered is returned, or nil if there are no violations. 236func (m *MetadataMatcher_PathSegment) Validate() error { 237 return m.validate(false) 238} 239 240// ValidateAll checks the field values on MetadataMatcher_PathSegment with the 241// rules defined in the proto definition for this message. If any rules are 242// violated, the result is a list of violation errors wrapped in 243// MetadataMatcher_PathSegmentMultiError, or nil if none found. 244func (m *MetadataMatcher_PathSegment) ValidateAll() error { 245 return m.validate(true) 246} 247 248func (m *MetadataMatcher_PathSegment) validate(all bool) error { 249 if m == nil { 250 return nil 251 } 252 253 var errors []error 254 255 switch m.Segment.(type) { 256 257 case *MetadataMatcher_PathSegment_Key: 258 259 if utf8.RuneCountInString(m.GetKey()) < 1 { 260 err := MetadataMatcher_PathSegmentValidationError{ 261 field: "Key", 262 reason: "value length must be at least 1 runes", 263 } 264 if !all { 265 return err 266 } 267 errors = append(errors, err) 268 } 269 270 default: 271 err := MetadataMatcher_PathSegmentValidationError{ 272 field: "Segment", 273 reason: "value is required", 274 } 275 if !all { 276 return err 277 } 278 errors = append(errors, err) 279 280 } 281 282 if len(errors) > 0 { 283 return MetadataMatcher_PathSegmentMultiError(errors) 284 } 285 return nil 286} 287 288// MetadataMatcher_PathSegmentMultiError is an error wrapping multiple 289// validation errors returned by MetadataMatcher_PathSegment.ValidateAll() if 290// the designated constraints aren't met. 291type MetadataMatcher_PathSegmentMultiError []error 292 293// Error returns a concatenation of all the error messages it wraps. 294func (m MetadataMatcher_PathSegmentMultiError) Error() string { 295 var msgs []string 296 for _, err := range m { 297 msgs = append(msgs, err.Error()) 298 } 299 return strings.Join(msgs, "; ") 300} 301 302// AllErrors returns a list of validation violation errors. 303func (m MetadataMatcher_PathSegmentMultiError) AllErrors() []error { return m } 304 305// MetadataMatcher_PathSegmentValidationError is the validation error returned 306// by MetadataMatcher_PathSegment.Validate if the designated constraints 307// aren't met. 308type MetadataMatcher_PathSegmentValidationError struct { 309 field string 310 reason string 311 cause error 312 key bool 313} 314 315// Field function returns field value. 316func (e MetadataMatcher_PathSegmentValidationError) Field() string { return e.field } 317 318// Reason function returns reason value. 319func (e MetadataMatcher_PathSegmentValidationError) Reason() string { return e.reason } 320 321// Cause function returns cause value. 322func (e MetadataMatcher_PathSegmentValidationError) Cause() error { return e.cause } 323 324// Key function returns key value. 325func (e MetadataMatcher_PathSegmentValidationError) Key() bool { return e.key } 326 327// ErrorName returns error name. 328func (e MetadataMatcher_PathSegmentValidationError) ErrorName() string { 329 return "MetadataMatcher_PathSegmentValidationError" 330} 331 332// Error satisfies the builtin error interface 333func (e MetadataMatcher_PathSegmentValidationError) Error() string { 334 cause := "" 335 if e.cause != nil { 336 cause = fmt.Sprintf(" | caused by: %v", e.cause) 337 } 338 339 key := "" 340 if e.key { 341 key = "key for " 342 } 343 344 return fmt.Sprintf( 345 "invalid %sMetadataMatcher_PathSegment.%s: %s%s", 346 key, 347 e.field, 348 e.reason, 349 cause) 350} 351 352var _ error = MetadataMatcher_PathSegmentValidationError{} 353 354var _ interface { 355 Field() string 356 Reason() string 357 Key() bool 358 Cause() error 359 ErrorName() string 360} = MetadataMatcher_PathSegmentValidationError{} 361