Debian Codegraph @

go/xds/core/v3/authority.pb.validate.go

raw symbols SCIP
1 // Code generated by protoc-gen-validate. DO NOT EDIT.
2 // source: xds/core/v3/authority.proto
3
4 package v3
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "sort"
15 "strings"
16 "time"
17 "unicode/utf8"
18
19 "google.golang.org/protobuf/types/known/anypb"
20 )
21
22 // ensure the imports are used
23 var (
24 _ = bytes.MinRead
25 _ = errors.New("")
26 _ = fmt.Print
27 _ = utf8.UTFMax
28 _ = (*regexp.Regexp)(nil)
29 _ = (*strings.Reader)(nil)
30 _ = net.IPv4len
31 _ = time.Duration(0)
32 _ = (*url.URL)(nil)
33 _ = (*mail.Address)(nil)
34 _ = anypb.Any{}
35 _ = sort.Sort
36 )
37
38 // Validate checks the field values on Authority with the rules defined in the
39 // proto definition for this message. If any rules are violated, the first
40 // error encountered is returned, or nil if there are no violations.
41 func (m *Authority) Validate() error {
42 return m.validate(false)
43 }
44
45 // ValidateAll checks the field values on Authority with the rules defined in
46 // the proto definition for this message. If any rules are violated, the
47 // result is a list of violation errors wrapped in AuthorityMultiError, or nil
48 // if none found.
49 func (m *Authority) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Authority) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if utf8.RuneCountInString(m.GetName()) < 1 {
61 err := AuthorityValidationError{
62 field: "Name",
63 reason: "value length must be at least 1 runes",
64 }
65 if !all {
66 return err
67 }
68 errors = append(errors, err)
69 }
70
71 if len(errors) > 0 {
72 return AuthorityMultiError(errors)
73 }
74
75 return nil
76 }
77
78 // AuthorityMultiError is an error wrapping multiple validation errors returned
79 // by Authority.ValidateAll() if the designated constraints aren't met.
80 type AuthorityMultiError []error
81
82 // Error returns a concatenation of all the error messages it wraps.
83 func (m AuthorityMultiError) Error() string {
84 msgs := make([]string, 0, len(m))
85 for _, err := range m {
86 msgs = append(msgs, err.Error())
87 }
88 return strings.Join(msgs, "; ")
89 }
90
91 // AllErrors returns a list of validation violation errors.
92 func (m AuthorityMultiError) AllErrors() []error { return m }
93
94 // AuthorityValidationError is the validation error returned by
95 // Authority.Validate if the designated constraints aren't met.
96 type AuthorityValidationError struct {
97 field string
98 reason string
99 cause error
100 key bool
101 }
102
103 // Field function returns field value.
104 func (e AuthorityValidationError) Field() string { return e.field }
105
106 // Reason function returns reason value.
107 func (e AuthorityValidationError) Reason() string { return e.reason }
108
109 // Cause function returns cause value.
110 func (e AuthorityValidationError) Cause() error { return e.cause }
111
112 // Key function returns key value.
113 func (e AuthorityValidationError) Key() bool { return e.key }
114
115 // ErrorName returns error name.
116 func (e AuthorityValidationError) ErrorName() string { return "AuthorityValidationError" }
117
118 // Error satisfies the builtin error interface
119 func (e AuthorityValidationError) Error() string {
120 cause := ""
121 if e.cause != nil {
122 cause = fmt.Sprintf(" | caused by: %v", e.cause)
123 }
124
125 key := ""
126 if e.key {
127 key = "key for "
128 }
129
130 return fmt.Sprintf(
131 "invalid %sAuthority.%s: %s%s",
132 key,
133 e.field,
134 e.reason,
135 cause)
136 }
137
138 var _ error = AuthorityValidationError{}
139
140 var _ interface {
141 Field() string
142 Reason() string
143 Key() bool
144 Cause() error
145 ErrorName() string
146 } = AuthorityValidationError{}