1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: envoy/config/core/v3/address.proto
3
4package envoy_config_core_v3
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 Pipe with the rules defined in the proto
39// definition for this message. If any rules are violated, the first error
40// encountered is returned, or nil if there are no violations.
41func (m *Pipe) Validate() error {
42	return m.validate(false)
43}
44
45// ValidateAll checks the field values on Pipe with the rules defined in the
46// proto definition for this message. If any rules are violated, the result is
47// a list of violation errors wrapped in PipeMultiError, or nil if none found.
48func (m *Pipe) ValidateAll() error {
49	return m.validate(true)
50}
51
52func (m *Pipe) validate(all bool) error {
53	if m == nil {
54		return nil
55	}
56
57	var errors []error
58
59	if utf8.RuneCountInString(m.GetPath()) < 1 {
60		err := PipeValidationError{
61			field:  "Path",
62			reason: "value length must be at least 1 runes",
63		}
64		if !all {
65			return err
66		}
67		errors = append(errors, err)
68	}
69
70	if m.GetMode() > 511 {
71		err := PipeValidationError{
72			field:  "Mode",
73			reason: "value must be less than or equal to 511",
74		}
75		if !all {
76			return err
77		}
78		errors = append(errors, err)
79	}
80
81	if len(errors) > 0 {
82		return PipeMultiError(errors)
83	}
84	return nil
85}
86
87// PipeMultiError is an error wrapping multiple validation errors returned by
88// Pipe.ValidateAll() if the designated constraints aren't met.
89type PipeMultiError []error
90
91// Error returns a concatenation of all the error messages it wraps.
92func (m PipeMultiError) Error() string {
93	var msgs []string
94	for _, err := range m {
95		msgs = append(msgs, err.Error())
96	}
97	return strings.Join(msgs, "; ")
98}
99
100// AllErrors returns a list of validation violation errors.
101func (m PipeMultiError) AllErrors() []error { return m }
102
103// PipeValidationError is the validation error returned by Pipe.Validate if the
104// designated constraints aren't met.
105type PipeValidationError struct {
106	field  string
107	reason string
108	cause  error
109	key    bool
110}
111
112// Field function returns field value.
113func (e PipeValidationError) Field() string { return e.field }
114
115// Reason function returns reason value.
116func (e PipeValidationError) Reason() string { return e.reason }
117
118// Cause function returns cause value.
119func (e PipeValidationError) Cause() error { return e.cause }
120
121// Key function returns key value.
122func (e PipeValidationError) Key() bool { return e.key }
123
124// ErrorName returns error name.
125func (e PipeValidationError) ErrorName() string { return "PipeValidationError" }
126
127// Error satisfies the builtin error interface
128func (e PipeValidationError) Error() string {
129	cause := ""
130	if e.cause != nil {
131		cause = fmt.Sprintf(" | caused by: %v", e.cause)
132	}
133
134	key := ""
135	if e.key {
136		key = "key for "
137	}
138
139	return fmt.Sprintf(
140		"invalid %sPipe.%s: %s%s",
141		key,
142		e.field,
143		e.reason,
144		cause)
145}
146
147var _ error = PipeValidationError{}
148
149var _ interface {
150	Field() string
151	Reason() string
152	Key() bool
153	Cause() error
154	ErrorName() string
155} = PipeValidationError{}
156
157// Validate checks the field values on EnvoyInternalAddress with the rules
158// defined in the proto definition for this message. If any rules are
159// violated, the first error encountered is returned, or nil if there are no violations.
160func (m *EnvoyInternalAddress) Validate() error {
161	return m.validate(false)
162}
163
164// ValidateAll checks the field values on EnvoyInternalAddress with the rules
165// defined in the proto definition for this message. If any rules are
166// violated, the result is a list of violation errors wrapped in
167// EnvoyInternalAddressMultiError, or nil if none found.
168func (m *EnvoyInternalAddress) ValidateAll() error {
169	return m.validate(true)
170}
171
172func (m *EnvoyInternalAddress) validate(all bool) error {
173	if m == nil {
174		return nil
175	}
176
177	var errors []error
178
179	switch m.AddressNameSpecifier.(type) {
180
181	case *EnvoyInternalAddress_ServerListenerName:
182		// no validation rules for ServerListenerName
183
184	default:
185		err := EnvoyInternalAddressValidationError{
186			field:  "AddressNameSpecifier",
187			reason: "value is required",
188		}
189		if !all {
190			return err
191		}
192		errors = append(errors, err)
193
194	}
195
196	if len(errors) > 0 {
197		return EnvoyInternalAddressMultiError(errors)
198	}
199	return nil
200}
201
202// EnvoyInternalAddressMultiError is an error wrapping multiple validation
203// errors returned by EnvoyInternalAddress.ValidateAll() if the designated
204// constraints aren't met.
205type EnvoyInternalAddressMultiError []error
206
207// Error returns a concatenation of all the error messages it wraps.
208func (m EnvoyInternalAddressMultiError) Error() string {
209	var msgs []string
210	for _, err := range m {
211		msgs = append(msgs, err.Error())
212	}
213	return strings.Join(msgs, "; ")
214}
215
216// AllErrors returns a list of validation violation errors.
217func (m EnvoyInternalAddressMultiError) AllErrors() []error { return m }
218
219// EnvoyInternalAddressValidationError is the validation error returned by
220// EnvoyInternalAddress.Validate if the designated constraints aren't met.
221type EnvoyInternalAddressValidationError struct {
222	field  string
223	reason string
224	cause  error
225	key    bool
226}
227
228// Field function returns field value.
229func (e EnvoyInternalAddressValidationError) Field() string { return e.field }
230
231// Reason function returns reason value.
232func (e EnvoyInternalAddressValidationError) Reason() string { return e.reason }
233
234// Cause function returns cause value.
235func (e EnvoyInternalAddressValidationError) Cause() error { return e.cause }
236
237// Key function returns key value.
238func (e EnvoyInternalAddressValidationError) Key() bool { return e.key }
239
240// ErrorName returns error name.
241func (e EnvoyInternalAddressValidationError) ErrorName() string {
242	return "EnvoyInternalAddressValidationError"
243}
244
245// Error satisfies the builtin error interface
246func (e EnvoyInternalAddressValidationError) Error() string {
247	cause := ""
248	if e.cause != nil {
249		cause = fmt.Sprintf(" | caused by: %v", e.cause)
250	}
251
252	key := ""
253	if e.key {
254		key = "key for "
255	}
256
257	return fmt.Sprintf(
258		"invalid %sEnvoyInternalAddress.%s: %s%s",
259		key,
260		e.field,
261		e.reason,
262		cause)
263}
264
265var _ error = EnvoyInternalAddressValidationError{}
266
267var _ interface {
268	Field() string
269	Reason() string
270	Key() bool
271	Cause() error
272	ErrorName() string
273} = EnvoyInternalAddressValidationError{}
274
275// Validate checks the field values on SocketAddress with the rules defined in
276// the proto definition for this message. If any rules are violated, the first
277// error encountered is returned, or nil if there are no violations.
278func (m *SocketAddress) Validate() error {
279	return m.validate(false)
280}
281
282// ValidateAll checks the field values on SocketAddress with the rules defined
283// in the proto definition for this message. If any rules are violated, the
284// result is a list of violation errors wrapped in SocketAddressMultiError, or
285// nil if none found.
286func (m *SocketAddress) ValidateAll() error {
287	return m.validate(true)
288}
289
290func (m *SocketAddress) validate(all bool) error {
291	if m == nil {
292		return nil
293	}
294
295	var errors []error
296
297	if _, ok := SocketAddress_Protocol_name[int32(m.GetProtocol())]; !ok {
298		err := SocketAddressValidationError{
299			field:  "Protocol",
300			reason: "value must be one of the defined enum values",
301		}
302		if !all {
303			return err
304		}
305		errors = append(errors, err)
306	}
307
308	if utf8.RuneCountInString(m.GetAddress()) < 1 {
309		err := SocketAddressValidationError{
310			field:  "Address",
311			reason: "value length must be at least 1 runes",
312		}
313		if !all {
314			return err
315		}
316		errors = append(errors, err)
317	}
318
319	// no validation rules for ResolverName
320
321	// no validation rules for Ipv4Compat
322
323	switch m.PortSpecifier.(type) {
324
325	case *SocketAddress_PortValue:
326
327		if m.GetPortValue() > 65535 {
328			err := SocketAddressValidationError{
329				field:  "PortValue",
330				reason: "value must be less than or equal to 65535",
331			}
332			if !all {
333				return err
334			}
335			errors = append(errors, err)
336		}
337
338	case *SocketAddress_NamedPort:
339		// no validation rules for NamedPort
340
341	default:
342		err := SocketAddressValidationError{
343			field:  "PortSpecifier",
344			reason: "value is required",
345		}
346		if !all {
347			return err
348		}
349		errors = append(errors, err)
350
351	}
352
353	if len(errors) > 0 {
354		return SocketAddressMultiError(errors)
355	}
356	return nil
357}
358
359// SocketAddressMultiError is an error wrapping multiple validation errors
360// returned by SocketAddress.ValidateAll() if the designated constraints
361// aren't met.
362type SocketAddressMultiError []error
363
364// Error returns a concatenation of all the error messages it wraps.
365func (m SocketAddressMultiError) Error() string {
366	var msgs []string
367	for _, err := range m {
368		msgs = append(msgs, err.Error())
369	}
370	return strings.Join(msgs, "; ")
371}
372
373// AllErrors returns a list of validation violation errors.
374func (m SocketAddressMultiError) AllErrors() []error { return m }
375
376// SocketAddressValidationError is the validation error returned by
377// SocketAddress.Validate if the designated constraints aren't met.
378type SocketAddressValidationError struct {
379	field  string
380	reason string
381	cause  error
382	key    bool
383}
384
385// Field function returns field value.
386func (e SocketAddressValidationError) Field() string { return e.field }
387
388// Reason function returns reason value.
389func (e SocketAddressValidationError) Reason() string { return e.reason }
390
391// Cause function returns cause value.
392func (e SocketAddressValidationError) Cause() error { return e.cause }
393
394// Key function returns key value.
395func (e SocketAddressValidationError) Key() bool { return e.key }
396
397// ErrorName returns error name.
398func (e SocketAddressValidationError) ErrorName() string { return "SocketAddressValidationError" }
399
400// Error satisfies the builtin error interface
401func (e SocketAddressValidationError) Error() string {
402	cause := ""
403	if e.cause != nil {
404		cause = fmt.Sprintf(" | caused by: %v", e.cause)
405	}
406
407	key := ""
408	if e.key {
409		key = "key for "
410	}
411
412	return fmt.Sprintf(
413		"invalid %sSocketAddress.%s: %s%s",
414		key,
415		e.field,
416		e.reason,
417		cause)
418}
419
420var _ error = SocketAddressValidationError{}
421
422var _ interface {
423	Field() string
424	Reason() string
425	Key() bool
426	Cause() error
427	ErrorName() string
428} = SocketAddressValidationError{}
429
430// Validate checks the field values on TcpKeepalive with the rules defined in
431// the proto definition for this message. If any rules are violated, the first
432// error encountered is returned, or nil if there are no violations.
433func (m *TcpKeepalive) Validate() error {
434	return m.validate(false)
435}
436
437// ValidateAll checks the field values on TcpKeepalive with the rules defined
438// in the proto definition for this message. If any rules are violated, the
439// result is a list of violation errors wrapped in TcpKeepaliveMultiError, or
440// nil if none found.
441func (m *TcpKeepalive) ValidateAll() error {
442	return m.validate(true)
443}
444
445func (m *TcpKeepalive) validate(all bool) error {
446	if m == nil {
447		return nil
448	}
449
450	var errors []error
451
452	if all {
453		switch v := interface{}(m.GetKeepaliveProbes()).(type) {
454		case interface{ ValidateAll() error }:
455			if err := v.ValidateAll(); err != nil {
456				errors = append(errors, TcpKeepaliveValidationError{
457					field:  "KeepaliveProbes",
458					reason: "embedded message failed validation",
459					cause:  err,
460				})
461			}
462		case interface{ Validate() error }:
463			if err := v.Validate(); err != nil {
464				errors = append(errors, TcpKeepaliveValidationError{
465					field:  "KeepaliveProbes",
466					reason: "embedded message failed validation",
467					cause:  err,
468				})
469			}
470		}
471	} else if v, ok := interface{}(m.GetKeepaliveProbes()).(interface{ Validate() error }); ok {
472		if err := v.Validate(); err != nil {
473			return TcpKeepaliveValidationError{
474				field:  "KeepaliveProbes",
475				reason: "embedded message failed validation",
476				cause:  err,
477			}
478		}
479	}
480
481	if all {
482		switch v := interface{}(m.GetKeepaliveTime()).(type) {
483		case interface{ ValidateAll() error }:
484			if err := v.ValidateAll(); err != nil {
485				errors = append(errors, TcpKeepaliveValidationError{
486					field:  "KeepaliveTime",
487					reason: "embedded message failed validation",
488					cause:  err,
489				})
490			}
491		case interface{ Validate() error }:
492			if err := v.Validate(); err != nil {
493				errors = append(errors, TcpKeepaliveValidationError{
494					field:  "KeepaliveTime",
495					reason: "embedded message failed validation",
496					cause:  err,
497				})
498			}
499		}
500	} else if v, ok := interface{}(m.GetKeepaliveTime()).(interface{ Validate() error }); ok {
501		if err := v.Validate(); err != nil {
502			return TcpKeepaliveValidationError{
503				field:  "KeepaliveTime",
504				reason: "embedded message failed validation",
505				cause:  err,
506			}
507		}
508	}
509
510	if all {
511		switch v := interface{}(m.GetKeepaliveInterval()).(type) {
512		case interface{ ValidateAll() error }:
513			if err := v.ValidateAll(); err != nil {
514				errors = append(errors, TcpKeepaliveValidationError{
515					field:  "KeepaliveInterval",
516					reason: "embedded message failed validation",
517					cause:  err,
518				})
519			}
520		case interface{ Validate() error }:
521			if err := v.Validate(); err != nil {
522				errors = append(errors, TcpKeepaliveValidationError{
523					field:  "KeepaliveInterval",
524					reason: "embedded message failed validation",
525					cause:  err,
526				})
527			}
528		}
529	} else if v, ok := interface{}(m.GetKeepaliveInterval()).(interface{ Validate() error }); ok {
530		if err := v.Validate(); err != nil {
531			return TcpKeepaliveValidationError{
532				field:  "KeepaliveInterval",
533				reason: "embedded message failed validation",
534				cause:  err,
535			}
536		}
537	}
538
539	if len(errors) > 0 {
540		return TcpKeepaliveMultiError(errors)
541	}
542	return nil
543}
544
545// TcpKeepaliveMultiError is an error wrapping multiple validation errors
546// returned by TcpKeepalive.ValidateAll() if the designated constraints aren't met.
547type TcpKeepaliveMultiError []error
548
549// Error returns a concatenation of all the error messages it wraps.
550func (m TcpKeepaliveMultiError) Error() string {
551	var msgs []string
552	for _, err := range m {
553		msgs = append(msgs, err.Error())
554	}
555	return strings.Join(msgs, "; ")
556}
557
558// AllErrors returns a list of validation violation errors.
559func (m TcpKeepaliveMultiError) AllErrors() []error { return m }
560
561// TcpKeepaliveValidationError is the validation error returned by
562// TcpKeepalive.Validate if the designated constraints aren't met.
563type TcpKeepaliveValidationError struct {
564	field  string
565	reason string
566	cause  error
567	key    bool
568}
569
570// Field function returns field value.
571func (e TcpKeepaliveValidationError) Field() string { return e.field }
572
573// Reason function returns reason value.
574func (e TcpKeepaliveValidationError) Reason() string { return e.reason }
575
576// Cause function returns cause value.
577func (e TcpKeepaliveValidationError) Cause() error { return e.cause }
578
579// Key function returns key value.
580func (e TcpKeepaliveValidationError) Key() bool { return e.key }
581
582// ErrorName returns error name.
583func (e TcpKeepaliveValidationError) ErrorName() string { return "TcpKeepaliveValidationError" }
584
585// Error satisfies the builtin error interface
586func (e TcpKeepaliveValidationError) Error() string {
587	cause := ""
588	if e.cause != nil {
589		cause = fmt.Sprintf(" | caused by: %v", e.cause)
590	}
591
592	key := ""
593	if e.key {
594		key = "key for "
595	}
596
597	return fmt.Sprintf(
598		"invalid %sTcpKeepalive.%s: %s%s",
599		key,
600		e.field,
601		e.reason,
602		cause)
603}
604
605var _ error = TcpKeepaliveValidationError{}
606
607var _ interface {
608	Field() string
609	Reason() string
610	Key() bool
611	Cause() error
612	ErrorName() string
613} = TcpKeepaliveValidationError{}
614
615// Validate checks the field values on BindConfig with the rules defined in the
616// proto definition for this message. If any rules are violated, the first
617// error encountered is returned, or nil if there are no violations.
618func (m *BindConfig) Validate() error {
619	return m.validate(false)
620}
621
622// ValidateAll checks the field values on BindConfig with the rules defined in
623// the proto definition for this message. If any rules are violated, the
624// result is a list of violation errors wrapped in BindConfigMultiError, or
625// nil if none found.
626func (m *BindConfig) ValidateAll() error {
627	return m.validate(true)
628}
629
630func (m *BindConfig) validate(all bool) error {
631	if m == nil {
632		return nil
633	}
634
635	var errors []error
636
637	if m.GetSourceAddress() == nil {
638		err := BindConfigValidationError{
639			field:  "SourceAddress",
640			reason: "value is required",
641		}
642		if !all {
643			return err
644		}
645		errors = append(errors, err)
646	}
647
648	if all {
649		switch v := interface{}(m.GetSourceAddress()).(type) {
650		case interface{ ValidateAll() error }:
651			if err := v.ValidateAll(); err != nil {
652				errors = append(errors, BindConfigValidationError{
653					field:  "SourceAddress",
654					reason: "embedded message failed validation",
655					cause:  err,
656				})
657			}
658		case interface{ Validate() error }:
659			if err := v.Validate(); err != nil {
660				errors = append(errors, BindConfigValidationError{
661					field:  "SourceAddress",
662					reason: "embedded message failed validation",
663					cause:  err,
664				})
665			}
666		}
667	} else if v, ok := interface{}(m.GetSourceAddress()).(interface{ Validate() error }); ok {
668		if err := v.Validate(); err != nil {
669			return BindConfigValidationError{
670				field:  "SourceAddress",
671				reason: "embedded message failed validation",
672				cause:  err,
673			}
674		}
675	}
676
677	if all {
678		switch v := interface{}(m.GetFreebind()).(type) {
679		case interface{ ValidateAll() error }:
680			if err := v.ValidateAll(); err != nil {
681				errors = append(errors, BindConfigValidationError{
682					field:  "Freebind",
683					reason: "embedded message failed validation",
684					cause:  err,
685				})
686			}
687		case interface{ Validate() error }:
688			if err := v.Validate(); err != nil {
689				errors = append(errors, BindConfigValidationError{
690					field:  "Freebind",
691					reason: "embedded message failed validation",
692					cause:  err,
693				})
694			}
695		}
696	} else if v, ok := interface{}(m.GetFreebind()).(interface{ Validate() error }); ok {
697		if err := v.Validate(); err != nil {
698			return BindConfigValidationError{
699				field:  "Freebind",
700				reason: "embedded message failed validation",
701				cause:  err,
702			}
703		}
704	}
705
706	for idx, item := range m.GetSocketOptions() {
707		_, _ = idx, item
708
709		if all {
710			switch v := interface{}(item).(type) {
711			case interface{ ValidateAll() error }:
712				if err := v.ValidateAll(); err != nil {
713					errors = append(errors, BindConfigValidationError{
714						field:  fmt.Sprintf("SocketOptions[%v]", idx),
715						reason: "embedded message failed validation",
716						cause:  err,
717					})
718				}
719			case interface{ Validate() error }:
720				if err := v.Validate(); err != nil {
721					errors = append(errors, BindConfigValidationError{
722						field:  fmt.Sprintf("SocketOptions[%v]", idx),
723						reason: "embedded message failed validation",
724						cause:  err,
725					})
726				}
727			}
728		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
729			if err := v.Validate(); err != nil {
730				return BindConfigValidationError{
731					field:  fmt.Sprintf("SocketOptions[%v]", idx),
732					reason: "embedded message failed validation",
733					cause:  err,
734				}
735			}
736		}
737
738	}
739
740	if len(errors) > 0 {
741		return BindConfigMultiError(errors)
742	}
743	return nil
744}
745
746// BindConfigMultiError is an error wrapping multiple validation errors
747// returned by BindConfig.ValidateAll() if the designated constraints aren't met.
748type BindConfigMultiError []error
749
750// Error returns a concatenation of all the error messages it wraps.
751func (m BindConfigMultiError) Error() string {
752	var msgs []string
753	for _, err := range m {
754		msgs = append(msgs, err.Error())
755	}
756	return strings.Join(msgs, "; ")
757}
758
759// AllErrors returns a list of validation violation errors.
760func (m BindConfigMultiError) AllErrors() []error { return m }
761
762// BindConfigValidationError is the validation error returned by
763// BindConfig.Validate if the designated constraints aren't met.
764type BindConfigValidationError struct {
765	field  string
766	reason string
767	cause  error
768	key    bool
769}
770
771// Field function returns field value.
772func (e BindConfigValidationError) Field() string { return e.field }
773
774// Reason function returns reason value.
775func (e BindConfigValidationError) Reason() string { return e.reason }
776
777// Cause function returns cause value.
778func (e BindConfigValidationError) Cause() error { return e.cause }
779
780// Key function returns key value.
781func (e BindConfigValidationError) Key() bool { return e.key }
782
783// ErrorName returns error name.
784func (e BindConfigValidationError) ErrorName() string { return "BindConfigValidationError" }
785
786// Error satisfies the builtin error interface
787func (e BindConfigValidationError) Error() string {
788	cause := ""
789	if e.cause != nil {
790		cause = fmt.Sprintf(" | caused by: %v", e.cause)
791	}
792
793	key := ""
794	if e.key {
795		key = "key for "
796	}
797
798	return fmt.Sprintf(
799		"invalid %sBindConfig.%s: %s%s",
800		key,
801		e.field,
802		e.reason,
803		cause)
804}
805
806var _ error = BindConfigValidationError{}
807
808var _ interface {
809	Field() string
810	Reason() string
811	Key() bool
812	Cause() error
813	ErrorName() string
814} = BindConfigValidationError{}
815
816// Validate checks the field values on Address with the rules defined in the
817// proto definition for this message. If any rules are violated, the first
818// error encountered is returned, or nil if there are no violations.
819func (m *Address) Validate() error {
820	return m.validate(false)
821}
822
823// ValidateAll checks the field values on Address with the rules defined in the
824// proto definition for this message. If any rules are violated, the result is
825// a list of violation errors wrapped in AddressMultiError, or nil if none found.
826func (m *Address) ValidateAll() error {
827	return m.validate(true)
828}
829
830func (m *Address) validate(all bool) error {
831	if m == nil {
832		return nil
833	}
834
835	var errors []error
836
837	switch m.Address.(type) {
838
839	case *Address_SocketAddress:
840
841		if all {
842			switch v := interface{}(m.GetSocketAddress()).(type) {
843			case interface{ ValidateAll() error }:
844				if err := v.ValidateAll(); err != nil {
845					errors = append(errors, AddressValidationError{
846						field:  "SocketAddress",
847						reason: "embedded message failed validation",
848						cause:  err,
849					})
850				}
851			case interface{ Validate() error }:
852				if err := v.Validate(); err != nil {
853					errors = append(errors, AddressValidationError{
854						field:  "SocketAddress",
855						reason: "embedded message failed validation",
856						cause:  err,
857					})
858				}
859			}
860		} else if v, ok := interface{}(m.GetSocketAddress()).(interface{ Validate() error }); ok {
861			if err := v.Validate(); err != nil {
862				return AddressValidationError{
863					field:  "SocketAddress",
864					reason: "embedded message failed validation",
865					cause:  err,
866				}
867			}
868		}
869
870	case *Address_Pipe:
871
872		if all {
873			switch v := interface{}(m.GetPipe()).(type) {
874			case interface{ ValidateAll() error }:
875				if err := v.ValidateAll(); err != nil {
876					errors = append(errors, AddressValidationError{
877						field:  "Pipe",
878						reason: "embedded message failed validation",
879						cause:  err,
880					})
881				}
882			case interface{ Validate() error }:
883				if err := v.Validate(); err != nil {
884					errors = append(errors, AddressValidationError{
885						field:  "Pipe",
886						reason: "embedded message failed validation",
887						cause:  err,
888					})
889				}
890			}
891		} else if v, ok := interface{}(m.GetPipe()).(interface{ Validate() error }); ok {
892			if err := v.Validate(); err != nil {
893				return AddressValidationError{
894					field:  "Pipe",
895					reason: "embedded message failed validation",
896					cause:  err,
897				}
898			}
899		}
900
901	case *Address_EnvoyInternalAddress:
902
903		if all {
904			switch v := interface{}(m.GetEnvoyInternalAddress()).(type) {
905			case interface{ ValidateAll() error }:
906				if err := v.ValidateAll(); err != nil {
907					errors = append(errors, AddressValidationError{
908						field:  "EnvoyInternalAddress",
909						reason: "embedded message failed validation",
910						cause:  err,
911					})
912				}
913			case interface{ Validate() error }:
914				if err := v.Validate(); err != nil {
915					errors = append(errors, AddressValidationError{
916						field:  "EnvoyInternalAddress",
917						reason: "embedded message failed validation",
918						cause:  err,
919					})
920				}
921			}
922		} else if v, ok := interface{}(m.GetEnvoyInternalAddress()).(interface{ Validate() error }); ok {
923			if err := v.Validate(); err != nil {
924				return AddressValidationError{
925					field:  "EnvoyInternalAddress",
926					reason: "embedded message failed validation",
927					cause:  err,
928				}
929			}
930		}
931
932	default:
933		err := AddressValidationError{
934			field:  "Address",
935			reason: "value is required",
936		}
937		if !all {
938			return err
939		}
940		errors = append(errors, err)
941
942	}
943
944	if len(errors) > 0 {
945		return AddressMultiError(errors)
946	}
947	return nil
948}
949
950// AddressMultiError is an error wrapping multiple validation errors returned
951// by Address.ValidateAll() if the designated constraints aren't met.
952type AddressMultiError []error
953
954// Error returns a concatenation of all the error messages it wraps.
955func (m AddressMultiError) Error() string {
956	var msgs []string
957	for _, err := range m {
958		msgs = append(msgs, err.Error())
959	}
960	return strings.Join(msgs, "; ")
961}
962
963// AllErrors returns a list of validation violation errors.
964func (m AddressMultiError) AllErrors() []error { return m }
965
966// AddressValidationError is the validation error returned by Address.Validate
967// if the designated constraints aren't met.
968type AddressValidationError struct {
969	field  string
970	reason string
971	cause  error
972	key    bool
973}
974
975// Field function returns field value.
976func (e AddressValidationError) Field() string { return e.field }
977
978// Reason function returns reason value.
979func (e AddressValidationError) Reason() string { return e.reason }
980
981// Cause function returns cause value.
982func (e AddressValidationError) Cause() error { return e.cause }
983
984// Key function returns key value.
985func (e AddressValidationError) Key() bool { return e.key }
986
987// ErrorName returns error name.
988func (e AddressValidationError) ErrorName() string { return "AddressValidationError" }
989
990// Error satisfies the builtin error interface
991func (e AddressValidationError) Error() string {
992	cause := ""
993	if e.cause != nil {
994		cause = fmt.Sprintf(" | caused by: %v", e.cause)
995	}
996
997	key := ""
998	if e.key {
999		key = "key for "
1000	}
1001
1002	return fmt.Sprintf(
1003		"invalid %sAddress.%s: %s%s",
1004		key,
1005		e.field,
1006		e.reason,
1007		cause)
1008}
1009
1010var _ error = AddressValidationError{}
1011
1012var _ interface {
1013	Field() string
1014	Reason() string
1015	Key() bool
1016	Cause() error
1017	ErrorName() string
1018} = AddressValidationError{}
1019
1020// Validate checks the field values on CidrRange with the rules defined in the
1021// proto definition for this message. If any rules are violated, the first
1022// error encountered is returned, or nil if there are no violations.
1023func (m *CidrRange) Validate() error {
1024	return m.validate(false)
1025}
1026
1027// ValidateAll checks the field values on CidrRange with the rules defined in
1028// the proto definition for this message. If any rules are violated, the
1029// result is a list of violation errors wrapped in CidrRangeMultiError, or nil
1030// if none found.
1031func (m *CidrRange) ValidateAll() error {
1032	return m.validate(true)
1033}
1034
1035func (m *CidrRange) validate(all bool) error {
1036	if m == nil {
1037		return nil
1038	}
1039
1040	var errors []error
1041
1042	if utf8.RuneCountInString(m.GetAddressPrefix()) < 1 {
1043		err := CidrRangeValidationError{
1044			field:  "AddressPrefix",
1045			reason: "value length must be at least 1 runes",
1046		}
1047		if !all {
1048			return err
1049		}
1050		errors = append(errors, err)
1051	}
1052
1053	if wrapper := m.GetPrefixLen(); wrapper != nil {
1054
1055		if wrapper.GetValue() > 128 {
1056			err := CidrRangeValidationError{
1057				field:  "PrefixLen",
1058				reason: "value must be less than or equal to 128",
1059			}
1060			if !all {
1061				return err
1062			}
1063			errors = append(errors, err)
1064		}
1065
1066	}
1067
1068	if len(errors) > 0 {
1069		return CidrRangeMultiError(errors)
1070	}
1071	return nil
1072}
1073
1074// CidrRangeMultiError is an error wrapping multiple validation errors returned
1075// by CidrRange.ValidateAll() if the designated constraints aren't met.
1076type CidrRangeMultiError []error
1077
1078// Error returns a concatenation of all the error messages it wraps.
1079func (m CidrRangeMultiError) Error() string {
1080	var msgs []string
1081	for _, err := range m {
1082		msgs = append(msgs, err.Error())
1083	}
1084	return strings.Join(msgs, "; ")
1085}
1086
1087// AllErrors returns a list of validation violation errors.
1088func (m CidrRangeMultiError) AllErrors() []error { return m }
1089
1090// CidrRangeValidationError is the validation error returned by
1091// CidrRange.Validate if the designated constraints aren't met.
1092type CidrRangeValidationError struct {
1093	field  string
1094	reason string
1095	cause  error
1096	key    bool
1097}
1098
1099// Field function returns field value.
1100func (e CidrRangeValidationError) Field() string { return e.field }
1101
1102// Reason function returns reason value.
1103func (e CidrRangeValidationError) Reason() string { return e.reason }
1104
1105// Cause function returns cause value.
1106func (e CidrRangeValidationError) Cause() error { return e.cause }
1107
1108// Key function returns key value.
1109func (e CidrRangeValidationError) Key() bool { return e.key }
1110
1111// ErrorName returns error name.
1112func (e CidrRangeValidationError) ErrorName() string { return "CidrRangeValidationError" }
1113
1114// Error satisfies the builtin error interface
1115func (e CidrRangeValidationError) Error() string {
1116	cause := ""
1117	if e.cause != nil {
1118		cause = fmt.Sprintf(" | caused by: %v", e.cause)
1119	}
1120
1121	key := ""
1122	if e.key {
1123		key = "key for "
1124	}
1125
1126	return fmt.Sprintf(
1127		"invalid %sCidrRange.%s: %s%s",
1128		key,
1129		e.field,
1130		e.reason,
1131		cause)
1132}
1133
1134var _ error = CidrRangeValidationError{}
1135
1136var _ interface {
1137	Field() string
1138	Reason() string
1139	Key() bool
1140	Cause() error
1141	ErrorName() string
1142} = CidrRangeValidationError{}
1143