Debian Codegraph @

envoy/config/trace/v3/lightstep.pb.validate.go

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