Debian Codegraph @

envoy/extensions/load_balancing_policies/wrr_locality/v3/wrr_locality.pb.validate.go

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