Debian Codegraph @

envoy/extensions/matching/input_matchers/runtime_fraction/v3/runtime_fraction.pb.validate.go

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