Debian Codegraph @

envoy/extensions/upstreams/tcp/v3/tcp_protocol_options.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/upstreams/tcp/v3/tcp_protocol_options.proto
4
5 package tcpv3
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 TcpProtocolOptions with the rules
40 // defined in the proto definition for this message. If any rules are
41 // violated, the first error encountered is returned, or nil if there are no violations.
42 func (m *TcpProtocolOptions) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on TcpProtocolOptions 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 // TcpProtocolOptionsMultiError, or nil if none found.
50 func (m *TcpProtocolOptions) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *TcpProtocolOptions) 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.GetIdleTimeout()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, TcpProtocolOptionsValidationError{
66 field: "IdleTimeout",
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, TcpProtocolOptionsValidationError{
74 field: "IdleTimeout",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetIdleTimeout()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return TcpProtocolOptionsValidationError{
83 field: "IdleTimeout",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if len(errors) > 0 {
91 return TcpProtocolOptionsMultiError(errors)
92 }
93
94 return nil
95 }
96
97 // TcpProtocolOptionsMultiError is an error wrapping multiple validation errors
98 // returned by TcpProtocolOptions.ValidateAll() if the designated constraints
99 // aren't met.
100 type TcpProtocolOptionsMultiError []error
101
102 // Error returns a concatenation of all the error messages it wraps.
103 func (m TcpProtocolOptionsMultiError) Error() string {
104 var msgs []string
105 for _, err := range m {
106 msgs = append(msgs, err.Error())
107 }
108 return strings.Join(msgs, "; ")
109 }
110
111 // AllErrors returns a list of validation violation errors.
112 func (m TcpProtocolOptionsMultiError) AllErrors() []error { return m }
113
114 // TcpProtocolOptionsValidationError is the validation error returned by
115 // TcpProtocolOptions.Validate if the designated constraints aren't met.
116 type TcpProtocolOptionsValidationError struct {
117 field string
118 reason string
119 cause error
120 key bool
121 }
122
123 // Field function returns field value.
124 func (e TcpProtocolOptionsValidationError) Field() string { return e.field }
125
126 // Reason function returns reason value.
127 func (e TcpProtocolOptionsValidationError) Reason() string { return e.reason }
128
129 // Cause function returns cause value.
130 func (e TcpProtocolOptionsValidationError) Cause() error { return e.cause }
131
132 // Key function returns key value.
133 func (e TcpProtocolOptionsValidationError) Key() bool { return e.key }
134
135 // ErrorName returns error name.
136 func (e TcpProtocolOptionsValidationError) ErrorName() string {
137 return "TcpProtocolOptionsValidationError"
138 }
139
140 // Error satisfies the builtin error interface
141 func (e TcpProtocolOptionsValidationError) Error() string {
142 cause := ""
143 if e.cause != nil {
144 cause = fmt.Sprintf(" | caused by: %v", e.cause)
145 }
146
147 key := ""
148 if e.key {
149 key = "key for "
150 }
151
152 return fmt.Sprintf(
153 "invalid %sTcpProtocolOptions.%s: %s%s",
154 key,
155 e.field,
156 e.reason,
157 cause)
158 }
159
160 var _ error = TcpProtocolOptionsValidationError{}
161
162 var _ interface {
163 Field() string
164 Reason() string
165 Key() bool
166 Cause() error
167 ErrorName() string
168 } = TcpProtocolOptionsValidationError{}