Debian Codegraph @

envoy/config/health_checker/redis/v2/redis.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/health_checker/redis/v2/redis.proto
4
5 package redisv2
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 Redis 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 *Redis) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Redis 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 RedisMultiError, or nil if none found.
49 func (m *Redis) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Redis) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 // no validation rules for Key
61
62 if len(errors) > 0 {
63 return RedisMultiError(errors)
64 }
65
66 return nil
67 }
68
69 // RedisMultiError is an error wrapping multiple validation errors returned by
70 // Redis.ValidateAll() if the designated constraints aren't met.
71 type RedisMultiError []error
72
73 // Error returns a concatenation of all the error messages it wraps.
74 func (m RedisMultiError) Error() string {
75 var msgs []string
76 for _, err := range m {
77 msgs = append(msgs, err.Error())
78 }
79 return strings.Join(msgs, "; ")
80 }
81
82 // AllErrors returns a list of validation violation errors.
83 func (m RedisMultiError) AllErrors() []error { return m }
84
85 // RedisValidationError is the validation error returned by Redis.Validate if
86 // the designated constraints aren't met.
87 type RedisValidationError struct {
88 field string
89 reason string
90 cause error
91 key bool
92 }
93
94 // Field function returns field value.
95 func (e RedisValidationError) Field() string { return e.field }
96
97 // Reason function returns reason value.
98 func (e RedisValidationError) Reason() string { return e.reason }
99
100 // Cause function returns cause value.
101 func (e RedisValidationError) Cause() error { return e.cause }
102
103 // Key function returns key value.
104 func (e RedisValidationError) Key() bool { return e.key }
105
106 // ErrorName returns error name.
107 func (e RedisValidationError) ErrorName() string { return "RedisValidationError" }
108
109 // Error satisfies the builtin error interface
110 func (e RedisValidationError) Error() string {
111 cause := ""
112 if e.cause != nil {
113 cause = fmt.Sprintf(" | caused by: %v", e.cause)
114 }
115
116 key := ""
117 if e.key {
118 key = "key for "
119 }
120
121 return fmt.Sprintf(
122 "invalid %sRedis.%s: %s%s",
123 key,
124 e.field,
125 e.reason,
126 cause)
127 }
128
129 var _ error = RedisValidationError{}
130
131 var _ interface {
132 Field() string
133 Reason() string
134 Key() bool
135 Cause() error
136 ErrorName() string
137 } = RedisValidationError{}