Debian Codegraph @

envoy/extensions/formatter/cel/v3/cel.pb.validate.go

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