Debian Codegraph @

envoy/config/core/v3/udp_socket_config.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/udp_socket_config.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 UdpSocketConfig 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 *UdpSocketConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on UdpSocketConfig 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 // UdpSocketConfigMultiError, or nil if none found.
50 func (m *UdpSocketConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *UdpSocketConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if wrapper := m.GetMaxRxDatagramSize(); wrapper != nil {
62
63 if val := wrapper.GetValue(); val <= 0 || val >= 65536 {
64 err := UdpSocketConfigValidationError{
65 field: "MaxRxDatagramSize",
66 reason: "value must be inside range (0, 65536)",
67 }
68 if !all {
69 return err
70 }
71 errors = append(errors, err)
72 }
73
74 }
75
76 if all {
77 switch v := interface{}(m.GetPreferGro()).(type) {
78 case interface{ ValidateAll() error }:
79 if err := v.ValidateAll(); err != nil {
80 errors = append(errors, UdpSocketConfigValidationError{
81 field: "PreferGro",
82 reason: "embedded message failed validation",
83 cause: err,
84 })
85 }
86 case interface{ Validate() error }:
87 if err := v.Validate(); err != nil {
88 errors = append(errors, UdpSocketConfigValidationError{
89 field: "PreferGro",
90 reason: "embedded message failed validation",
91 cause: err,
92 })
93 }
94 }
95 } else if v, ok := interface{}(m.GetPreferGro()).(interface{ Validate() error }); ok {
96 if err := v.Validate(); err != nil {
97 return UdpSocketConfigValidationError{
98 field: "PreferGro",
99 reason: "embedded message failed validation",
100 cause: err,
101 }
102 }
103 }
104
105 if len(errors) > 0 {
106 return UdpSocketConfigMultiError(errors)
107 }
108
109 return nil
110 }
111
112 // UdpSocketConfigMultiError is an error wrapping multiple validation errors
113 // returned by UdpSocketConfig.ValidateAll() if the designated constraints
114 // aren't met.
115 type UdpSocketConfigMultiError []error
116
117 // Error returns a concatenation of all the error messages it wraps.
118 func (m UdpSocketConfigMultiError) Error() string {
119 var msgs []string
120 for _, err := range m {
121 msgs = append(msgs, err.Error())
122 }
123 return strings.Join(msgs, "; ")
124 }
125
126 // AllErrors returns a list of validation violation errors.
127 func (m UdpSocketConfigMultiError) AllErrors() []error { return m }
128
129 // UdpSocketConfigValidationError is the validation error returned by
130 // UdpSocketConfig.Validate if the designated constraints aren't met.
131 type UdpSocketConfigValidationError struct {
132 field string
133 reason string
134 cause error
135 key bool
136 }
137
138 // Field function returns field value.
139 func (e UdpSocketConfigValidationError) Field() string { return e.field }
140
141 // Reason function returns reason value.
142 func (e UdpSocketConfigValidationError) Reason() string { return e.reason }
143
144 // Cause function returns cause value.
145 func (e UdpSocketConfigValidationError) Cause() error { return e.cause }
146
147 // Key function returns key value.
148 func (e UdpSocketConfigValidationError) Key() bool { return e.key }
149
150 // ErrorName returns error name.
151 func (e UdpSocketConfigValidationError) ErrorName() string { return "UdpSocketConfigValidationError" }
152
153 // Error satisfies the builtin error interface
154 func (e UdpSocketConfigValidationError) Error() string {
155 cause := ""
156 if e.cause != nil {
157 cause = fmt.Sprintf(" | caused by: %v", e.cause)
158 }
159
160 key := ""
161 if e.key {
162 key = "key for "
163 }
164
165 return fmt.Sprintf(
166 "invalid %sUdpSocketConfig.%s: %s%s",
167 key,
168 e.field,
169 e.reason,
170 cause)
171 }
172
173 var _ error = UdpSocketConfigValidationError{}
174
175 var _ interface {
176 Field() string
177 Reason() string
178 Key() bool
179 Cause() error
180 ErrorName() string
181 } = UdpSocketConfigValidationError{}