Debian Codegraph @

envoy/config/core/v3/socket_cmsg_headers.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/socket_cmsg_headers.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 SocketCmsgHeaders with the rules defined
40 // in the proto definition for this message. If any rules are violated, the
41 // first error encountered is returned, or nil if there are no violations.
42 func (m *SocketCmsgHeaders) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on SocketCmsgHeaders with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // SocketCmsgHeadersMultiError, or nil if none found.
50 func (m *SocketCmsgHeaders) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *SocketCmsgHeaders) 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.GetLevel()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, SocketCmsgHeadersValidationError{
66 field: "Level",
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, SocketCmsgHeadersValidationError{
74 field: "Level",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetLevel()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return SocketCmsgHeadersValidationError{
83 field: "Level",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if all {
91 switch v := interface{}(m.GetType()).(type) {
92 case interface{ ValidateAll() error }:
93 if err := v.ValidateAll(); err != nil {
94 errors = append(errors, SocketCmsgHeadersValidationError{
95 field: "Type",
96 reason: "embedded message failed validation",
97 cause: err,
98 })
99 }
100 case interface{ Validate() error }:
101 if err := v.Validate(); err != nil {
102 errors = append(errors, SocketCmsgHeadersValidationError{
103 field: "Type",
104 reason: "embedded message failed validation",
105 cause: err,
106 })
107 }
108 }
109 } else if v, ok := interface{}(m.GetType()).(interface{ Validate() error }); ok {
110 if err := v.Validate(); err != nil {
111 return SocketCmsgHeadersValidationError{
112 field: "Type",
113 reason: "embedded message failed validation",
114 cause: err,
115 }
116 }
117 }
118
119 // no validation rules for ExpectedSize
120
121 if len(errors) > 0 {
122 return SocketCmsgHeadersMultiError(errors)
123 }
124
125 return nil
126 }
127
128 // SocketCmsgHeadersMultiError is an error wrapping multiple validation errors
129 // returned by SocketCmsgHeaders.ValidateAll() if the designated constraints
130 // aren't met.
131 type SocketCmsgHeadersMultiError []error
132
133 // Error returns a concatenation of all the error messages it wraps.
134 func (m SocketCmsgHeadersMultiError) Error() string {
135 var msgs []string
136 for _, err := range m {
137 msgs = append(msgs, err.Error())
138 }
139 return strings.Join(msgs, "; ")
140 }
141
142 // AllErrors returns a list of validation violation errors.
143 func (m SocketCmsgHeadersMultiError) AllErrors() []error { return m }
144
145 // SocketCmsgHeadersValidationError is the validation error returned by
146 // SocketCmsgHeaders.Validate if the designated constraints aren't met.
147 type SocketCmsgHeadersValidationError struct {
148 field string
149 reason string
150 cause error
151 key bool
152 }
153
154 // Field function returns field value.
155 func (e SocketCmsgHeadersValidationError) Field() string { return e.field }
156
157 // Reason function returns reason value.
158 func (e SocketCmsgHeadersValidationError) Reason() string { return e.reason }
159
160 // Cause function returns cause value.
161 func (e SocketCmsgHeadersValidationError) Cause() error { return e.cause }
162
163 // Key function returns key value.
164 func (e SocketCmsgHeadersValidationError) Key() bool { return e.key }
165
166 // ErrorName returns error name.
167 func (e SocketCmsgHeadersValidationError) ErrorName() string {
168 return "SocketCmsgHeadersValidationError"
169 }
170
171 // Error satisfies the builtin error interface
172 func (e SocketCmsgHeadersValidationError) Error() string {
173 cause := ""
174 if e.cause != nil {
175 cause = fmt.Sprintf(" | caused by: %v", e.cause)
176 }
177
178 key := ""
179 if e.key {
180 key = "key for "
181 }
182
183 return fmt.Sprintf(
184 "invalid %sSocketCmsgHeaders.%s: %s%s",
185 key,
186 e.field,
187 e.reason,
188 cause)
189 }
190
191 var _ error = SocketCmsgHeadersValidationError{}
192
193 var _ interface {
194 Field() string
195 Reason() string
196 Key() bool
197 Cause() error
198 ErrorName() string
199 } = SocketCmsgHeadersValidationError{}