Debian Codegraph @

envoy/config/cluster/v3/filter.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/cluster/v3/filter.proto
4
5 package clusterv3
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 Filter with the rules defined in the
40 // 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 *Filter) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Filter with the rules defined in the
47 // proto definition for this message. If any rules are violated, the result is
48 // a list of violation errors wrapped in FilterMultiError, or nil if none found.
49 func (m *Filter) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Filter) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if utf8.RuneCountInString(m.GetName()) < 1 {
61 err := FilterValidationError{
62 field: "Name",
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 all {
72 switch v := interface{}(m.GetTypedConfig()).(type) {
73 case interface{ ValidateAll() error }:
74 if err := v.ValidateAll(); err != nil {
75 errors = append(errors, FilterValidationError{
76 field: "TypedConfig",
77 reason: "embedded message failed validation",
78 cause: err,
79 })
80 }
81 case interface{ Validate() error }:
82 if err := v.Validate(); err != nil {
83 errors = append(errors, FilterValidationError{
84 field: "TypedConfig",
85 reason: "embedded message failed validation",
86 cause: err,
87 })
88 }
89 }
90 } else if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
91 if err := v.Validate(); err != nil {
92 return FilterValidationError{
93 field: "TypedConfig",
94 reason: "embedded message failed validation",
95 cause: err,
96 }
97 }
98 }
99
100 if all {
101 switch v := interface{}(m.GetConfigDiscovery()).(type) {
102 case interface{ ValidateAll() error }:
103 if err := v.ValidateAll(); err != nil {
104 errors = append(errors, FilterValidationError{
105 field: "ConfigDiscovery",
106 reason: "embedded message failed validation",
107 cause: err,
108 })
109 }
110 case interface{ Validate() error }:
111 if err := v.Validate(); err != nil {
112 errors = append(errors, FilterValidationError{
113 field: "ConfigDiscovery",
114 reason: "embedded message failed validation",
115 cause: err,
116 })
117 }
118 }
119 } else if v, ok := interface{}(m.GetConfigDiscovery()).(interface{ Validate() error }); ok {
120 if err := v.Validate(); err != nil {
121 return FilterValidationError{
122 field: "ConfigDiscovery",
123 reason: "embedded message failed validation",
124 cause: err,
125 }
126 }
127 }
128
129 if len(errors) > 0 {
130 return FilterMultiError(errors)
131 }
132
133 return nil
134 }
135
136 // FilterMultiError is an error wrapping multiple validation errors returned by
137 // Filter.ValidateAll() if the designated constraints aren't met.
138 type FilterMultiError []error
139
140 // Error returns a concatenation of all the error messages it wraps.
141 func (m FilterMultiError) Error() string {
142 var msgs []string
143 for _, err := range m {
144 msgs = append(msgs, err.Error())
145 }
146 return strings.Join(msgs, "; ")
147 }
148
149 // AllErrors returns a list of validation violation errors.
150 func (m FilterMultiError) AllErrors() []error { return m }
151
152 // FilterValidationError is the validation error returned by Filter.Validate if
153 // the designated constraints aren't met.
154 type FilterValidationError struct {
155 field string
156 reason string
157 cause error
158 key bool
159 }
160
161 // Field function returns field value.
162 func (e FilterValidationError) Field() string { return e.field }
163
164 // Reason function returns reason value.
165 func (e FilterValidationError) Reason() string { return e.reason }
166
167 // Cause function returns cause value.
168 func (e FilterValidationError) Cause() error { return e.cause }
169
170 // Key function returns key value.
171 func (e FilterValidationError) Key() bool { return e.key }
172
173 // ErrorName returns error name.
174 func (e FilterValidationError) ErrorName() string { return "FilterValidationError" }
175
176 // Error satisfies the builtin error interface
177 func (e FilterValidationError) Error() string {
178 cause := ""
179 if e.cause != nil {
180 cause = fmt.Sprintf(" | caused by: %v", e.cause)
181 }
182
183 key := ""
184 if e.key {
185 key = "key for "
186 }
187
188 return fmt.Sprintf(
189 "invalid %sFilter.%s: %s%s",
190 key,
191 e.field,
192 e.reason,
193 cause)
194 }
195
196 var _ error = FilterValidationError{}
197
198 var _ interface {
199 Field() string
200 Reason() string
201 Key() bool
202 Cause() error
203 ErrorName() string
204 } = FilterValidationError{}