github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/type/http_status.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/type/http_status.proto 3 4 package envoy_type 5 6 import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "strings" 15 "time" 16 "unicode/utf8" 17 18 "google.golang.org/protobuf/types/known/anypb" 19 ) 20 21 // ensure the imports are used 22 var ( 23 _ = bytes.MinRead 24 _ = errors.New("") 25 _ = fmt.Print 26 _ = utf8.UTFMax 27 _ = (*regexp.Regexp)(nil) 28 _ = (*strings.Reader)(nil) 29 _ = net.IPv4len 30 _ = time.Duration(0) 31 _ = (*url.URL)(nil) 32 _ = (*mail.Address)(nil) 33 _ = anypb.Any{} 34 ) 35 36 // Validate checks the field values on HttpStatus with the rules defined in the 37 // proto definition for this message. If any rules are violated, an error is returned. 38 func (m *HttpStatus) Validate() error { 39 if m == nil { 40 return nil 41 } 42 43 if _, ok := _HttpStatus_Code_NotInLookup[m.GetCode()]; ok { 44 return HttpStatusValidationError{ 45 field: "Code", 46 reason: "value must not be in list [0]", 47 } 48 } 49 50 if _, ok := StatusCode_name[int32(m.GetCode())]; !ok { 51 return HttpStatusValidationError{ 52 field: "Code", 53 reason: "value must be one of the defined enum values", 54 } 55 } 56 57 return nil 58 } 59 60 // HttpStatusValidationError is the validation error returned by 61 // HttpStatus.Validate if the designated constraints aren't met. 62 type HttpStatusValidationError struct { 63 field string 64 reason string 65 cause error 66 key bool 67 } 68 69 // Field function returns field value. 70 func (e HttpStatusValidationError) Field() string { return e.field } 71 72 // Reason function returns reason value. 73 func (e HttpStatusValidationError) Reason() string { return e.reason } 74 75 // Cause function returns cause value. 76 func (e HttpStatusValidationError) Cause() error { return e.cause } 77 78 // Key function returns key value. 79 func (e HttpStatusValidationError) Key() bool { return e.key } 80 81 // ErrorName returns error name. 82 func (e HttpStatusValidationError) ErrorName() string { return "HttpStatusValidationError" } 83 84 // Error satisfies the builtin error interface 85 func (e HttpStatusValidationError) Error() string { 86 cause := "" 87 if e.cause != nil { 88 cause = fmt.Sprintf(" | caused by: %v", e.cause) 89 } 90 91 key := "" 92 if e.key { 93 key = "key for " 94 } 95 96 return fmt.Sprintf( 97 "invalid %sHttpStatus.%s: %s%s", 98 key, 99 e.field, 100 e.reason, 101 cause) 102 } 103 104 var _ error = HttpStatusValidationError{} 105 106 var _ interface { 107 Field() string 108 Reason() string 109 Key() bool 110 Cause() error 111 ErrorName() string 112 } = HttpStatusValidationError{} 113 114 var _HttpStatus_Code_NotInLookup = map[StatusCode]struct{}{ 115 0: {}, 116 }