Debian Codegraph @

envoy/config/trace/v2/datadog.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/datadog.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 DatadogConfig with the rules defined in
40 // the proto definition for this message. If any rules are violated, the first
41 // error encountered is returned, or nil if there are no violations.
42 func (m *DatadogConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on DatadogConfig with the rules defined
47 // in the proto definition for this message. If any rules are violated, the
48 // result is a list of violation errors wrapped in DatadogConfigMultiError, or
49 // nil if none found.
50 func (m *DatadogConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *DatadogConfig) 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 := DatadogConfigValidationError{
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.GetServiceName()) < 1 {
73 err := DatadogConfigValidationError{
74 field: "ServiceName",
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 if len(errors) > 0 {
84 return DatadogConfigMultiError(errors)
85 }
86
87 return nil
88 }
89
90 // DatadogConfigMultiError is an error wrapping multiple validation errors
91 // returned by DatadogConfig.ValidateAll() if the designated constraints
92 // aren't met.
93 type DatadogConfigMultiError []error
94
95 // Error returns a concatenation of all the error messages it wraps.
96 func (m DatadogConfigMultiError) Error() string {
97 var msgs []string
98 for _, err := range m {
99 msgs = append(msgs, err.Error())
100 }
101 return strings.Join(msgs, "; ")
102 }
103
104 // AllErrors returns a list of validation violation errors.
105 func (m DatadogConfigMultiError) AllErrors() []error { return m }
106
107 // DatadogConfigValidationError is the validation error returned by
108 // DatadogConfig.Validate if the designated constraints aren't met.
109 type DatadogConfigValidationError struct {
110 field string
111 reason string
112 cause error
113 key bool
114 }
115
116 // Field function returns field value.
117 func (e DatadogConfigValidationError) Field() string { return e.field }
118
119 // Reason function returns reason value.
120 func (e DatadogConfigValidationError) Reason() string { return e.reason }
121
122 // Cause function returns cause value.
123 func (e DatadogConfigValidationError) Cause() error { return e.cause }
124
125 // Key function returns key value.
126 func (e DatadogConfigValidationError) Key() bool { return e.key }
127
128 // ErrorName returns error name.
129 func (e DatadogConfigValidationError) ErrorName() string { return "DatadogConfigValidationError" }
130
131 // Error satisfies the builtin error interface
132 func (e DatadogConfigValidationError) Error() string {
133 cause := ""
134 if e.cause != nil {
135 cause = fmt.Sprintf(" | caused by: %v", e.cause)
136 }
137
138 key := ""
139 if e.key {
140 key = "key for "
141 }
142
143 return fmt.Sprintf(
144 "invalid %sDatadogConfig.%s: %s%s",
145 key,
146 e.field,
147 e.reason,
148 cause)
149 }
150
151 var _ error = DatadogConfigValidationError{}
152
153 var _ interface {
154 Field() string
155 Reason() string
156 Key() bool
157 Cause() error
158 ErrorName() string
159 } = DatadogConfigValidationError{}