Debian Codegraph @

envoy/extensions/stat_sinks/wasm/v3/wasm.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/wasm/v3/wasm.proto
4
5 package wasmv3
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 Wasm with the rules defined in the proto
40 // definition for this message. If any rules are violated, the first error
41 // encountered is returned, or nil if there are no violations.
42 func (m *Wasm) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Wasm 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 WasmMultiError, or nil if none found.
49 func (m *Wasm) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Wasm) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if all {
61 switch v := interface{}(m.GetConfig()).(type) {
62 case interface{ ValidateAll() error }:
63 if err := v.ValidateAll(); err != nil {
64 errors = append(errors, WasmValidationError{
65 field: "Config",
66 reason: "embedded message failed validation",
67 cause: err,
68 })
69 }
70 case interface{ Validate() error }:
71 if err := v.Validate(); err != nil {
72 errors = append(errors, WasmValidationError{
73 field: "Config",
74 reason: "embedded message failed validation",
75 cause: err,
76 })
77 }
78 }
79 } else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
80 if err := v.Validate(); err != nil {
81 return WasmValidationError{
82 field: "Config",
83 reason: "embedded message failed validation",
84 cause: err,
85 }
86 }
87 }
88
89 if len(errors) > 0 {
90 return WasmMultiError(errors)
91 }
92
93 return nil
94 }
95
96 // WasmMultiError is an error wrapping multiple validation errors returned by
97 // Wasm.ValidateAll() if the designated constraints aren't met.
98 type WasmMultiError []error
99
100 // Error returns a concatenation of all the error messages it wraps.
101 func (m WasmMultiError) Error() string {
102 var msgs []string
103 for _, err := range m {
104 msgs = append(msgs, err.Error())
105 }
106 return strings.Join(msgs, "; ")
107 }
108
109 // AllErrors returns a list of validation violation errors.
110 func (m WasmMultiError) AllErrors() []error { return m }
111
112 // WasmValidationError is the validation error returned by Wasm.Validate if the
113 // designated constraints aren't met.
114 type WasmValidationError struct {
115 field string
116 reason string
117 cause error
118 key bool
119 }
120
121 // Field function returns field value.
122 func (e WasmValidationError) Field() string { return e.field }
123
124 // Reason function returns reason value.
125 func (e WasmValidationError) Reason() string { return e.reason }
126
127 // Cause function returns cause value.
128 func (e WasmValidationError) Cause() error { return e.cause }
129
130 // Key function returns key value.
131 func (e WasmValidationError) Key() bool { return e.key }
132
133 // ErrorName returns error name.
134 func (e WasmValidationError) ErrorName() string { return "WasmValidationError" }
135
136 // Error satisfies the builtin error interface
137 func (e WasmValidationError) Error() string {
138 cause := ""
139 if e.cause != nil {
140 cause = fmt.Sprintf(" | caused by: %v", e.cause)
141 }
142
143 key := ""
144 if e.key {
145 key = "key for "
146 }
147
148 return fmt.Sprintf(
149 "invalid %sWasm.%s: %s%s",
150 key,
151 e.field,
152 e.reason,
153 cause)
154 }
155
156 var _ error = WasmValidationError{}
157
158 var _ interface {
159 Field() string
160 Reason() string
161 Key() bool
162 Cause() error
163 ErrorName() string
164 } = WasmValidationError{}