Debian Codegraph @

envoy/extensions/stat_sinks/graphite_statsd/v3/graphite_statsd.pb.validate.go

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