Debian Codegraph @

envoy/config/trace/v2/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/v2/lightstep.proto
4
5 package tracev2
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 len(m.GetCollectorCluster()) < 1 {
62 err := LightstepConfigValidationError{
63 field: "CollectorCluster",
64 reason: "value length must be at least 1 bytes",
65 }
66 if !all {
67 return err
68 }
69 errors = append(errors, err)
70 }
71
72 if len(m.GetAccessTokenFile()) < 1 {
73 err := LightstepConfigValidationError{
74 field: "AccessTokenFile",
75 reason: "value length must be at least 1 bytes",
76 }
77 if !all {
78 return err
79 }
80 errors = append(errors, err)
81 }
82
83 for idx, item := range m.GetPropagationModes() {
84 _, _ = idx, item
85
86 if _, ok := LightstepConfig_PropagationMode_name[int32(item)]; !ok {
87 err := LightstepConfigValidationError{
88 field: fmt.Sprintf("PropagationModes[%v]", idx),
89 reason: "value must be one of the defined enum values",
90 }
91 if !all {
92 return err
93 }
94 errors = append(errors, err)
95 }
96
97 }
98
99 if len(errors) > 0 {
100 return LightstepConfigMultiError(errors)
101 }
102
103 return nil
104 }
105
106 // LightstepConfigMultiError is an error wrapping multiple validation errors
107 // returned by LightstepConfig.ValidateAll() if the designated constraints
108 // aren't met.
109 type LightstepConfigMultiError []error
110
111 // Error returns a concatenation of all the error messages it wraps.
112 func (m LightstepConfigMultiError) Error() string {
113 var msgs []string
114 for _, err := range m {
115 msgs = append(msgs, err.Error())
116 }
117 return strings.Join(msgs, "; ")
118 }
119
120 // AllErrors returns a list of validation violation errors.
121 func (m LightstepConfigMultiError) AllErrors() []error { return m }
122
123 // LightstepConfigValidationError is the validation error returned by
124 // LightstepConfig.Validate if the designated constraints aren't met.
125 type LightstepConfigValidationError struct {
126 field string
127 reason string
128 cause error
129 key bool
130 }
131
132 // Field function returns field value.
133 func (e LightstepConfigValidationError) Field() string { return e.field }
134
135 // Reason function returns reason value.
136 func (e LightstepConfigValidationError) Reason() string { return e.reason }
137
138 // Cause function returns cause value.
139 func (e LightstepConfigValidationError) Cause() error { return e.cause }
140
141 // Key function returns key value.
142 func (e LightstepConfigValidationError) Key() bool { return e.key }
143
144 // ErrorName returns error name.
145 func (e LightstepConfigValidationError) ErrorName() string { return "LightstepConfigValidationError" }
146
147 // Error satisfies the builtin error interface
148 func (e LightstepConfigValidationError) Error() string {
149 cause := ""
150 if e.cause != nil {
151 cause = fmt.Sprintf(" | caused by: %v", e.cause)
152 }
153
154 key := ""
155 if e.key {
156 key = "key for "
157 }
158
159 return fmt.Sprintf(
160 "invalid %sLightstepConfig.%s: %s%s",
161 key,
162 e.field,
163 e.reason,
164 cause)
165 }
166
167 var _ error = LightstepConfigValidationError{}
168
169 var _ interface {
170 Field() string
171 Reason() string
172 Key() bool
173 Cause() error
174 ErrorName() string
175 } = LightstepConfigValidationError{}