Debian Codegraph @

envoy/extensions/quic/connection_debug_visitor/quic_stats/v3/quic_stats.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/quic/connection_debug_visitor/quic_stats/v3/quic_stats.proto
4
5 package quic_statsv3
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 Config with the rules defined in the
40 // 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 *Config) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Config with the rules defined in the
47 // proto definition for this message. If any rules are violated, the result is
48 // a list of violation errors wrapped in ConfigMultiError, or nil if none found.
49 func (m *Config) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Config) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if d := m.GetUpdatePeriod(); d != nil {
61 dur, err := d.AsDuration(), d.CheckValid()
62 if err != nil {
63 err = ConfigValidationError{
64 field: "UpdatePeriod",
65 reason: "value is not a valid duration",
66 cause: err,
67 }
68 if !all {
69 return err
70 }
71 errors = append(errors, err)
72 } else {
73
74 gte := time.Duration(0*time.Second + 1000000*time.Nanosecond)
75
76 if dur < gte {
77 err := ConfigValidationError{
78 field: "UpdatePeriod",
79 reason: "value must be greater than or equal to 1ms",
80 }
81 if !all {
82 return err
83 }
84 errors = append(errors, err)
85 }
86
87 }
88 }
89
90 if len(errors) > 0 {
91 return ConfigMultiError(errors)
92 }
93
94 return nil
95 }
96
97 // ConfigMultiError is an error wrapping multiple validation errors returned by
98 // Config.ValidateAll() if the designated constraints aren't met.
99 type ConfigMultiError []error
100
101 // Error returns a concatenation of all the error messages it wraps.
102 func (m ConfigMultiError) Error() string {
103 var msgs []string
104 for _, err := range m {
105 msgs = append(msgs, err.Error())
106 }
107 return strings.Join(msgs, "; ")
108 }
109
110 // AllErrors returns a list of validation violation errors.
111 func (m ConfigMultiError) AllErrors() []error { return m }
112
113 // ConfigValidationError is the validation error returned by Config.Validate if
114 // the designated constraints aren't met.
115 type ConfigValidationError struct {
116 field string
117 reason string
118 cause error
119 key bool
120 }
121
122 // Field function returns field value.
123 func (e ConfigValidationError) Field() string { return e.field }
124
125 // Reason function returns reason value.
126 func (e ConfigValidationError) Reason() string { return e.reason }
127
128 // Cause function returns cause value.
129 func (e ConfigValidationError) Cause() error { return e.cause }
130
131 // Key function returns key value.
132 func (e ConfigValidationError) Key() bool { return e.key }
133
134 // ErrorName returns error name.
135 func (e ConfigValidationError) ErrorName() string { return "ConfigValidationError" }
136
137 // Error satisfies the builtin error interface
138 func (e ConfigValidationError) Error() string {
139 cause := ""
140 if e.cause != nil {
141 cause = fmt.Sprintf(" | caused by: %v", e.cause)
142 }
143
144 key := ""
145 if e.key {
146 key = "key for "
147 }
148
149 return fmt.Sprintf(
150 "invalid %sConfig.%s: %s%s",
151 key,
152 e.field,
153 e.reason,
154 cause)
155 }
156
157 var _ error = ConfigValidationError{}
158
159 var _ interface {
160 Field() string
161 Reason() string
162 Key() bool
163 Cause() error
164 ErrorName() string
165 } = ConfigValidationError{}