Debian Codegraph @

envoy/extensions/router/cluster_specifiers/lua/v3/lua.pb.validate.go

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