Debian Codegraph @

envoy/config/core/v3/http_service.pb.validate.go

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