Debian Codegraph @

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