Debian Codegraph @

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