You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

465 lines
12 KiB

// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: google/api/http.proto
package annotations
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"sort"
"strings"
"time"
"unicode/utf8"
"google.golang.org/protobuf/types/known/anypb"
)
// ensure the imports are used
var (
_ = bytes.MinRead
_ = errors.New("")
_ = fmt.Print
_ = utf8.UTFMax
_ = (*regexp.Regexp)(nil)
_ = (*strings.Reader)(nil)
_ = net.IPv4len
_ = time.Duration(0)
_ = (*url.URL)(nil)
_ = (*mail.Address)(nil)
_ = anypb.Any{}
_ = sort.Sort
)
// Validate checks the field values on Http with the rules defined in the proto
// definition for this message. If any rules are violated, the first error
// encountered is returned, or nil if there are no violations.
func (m *Http) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Http with the rules defined in the
// proto definition for this message. If any rules are violated, the result is
// a list of violation errors wrapped in HttpMultiError, or nil if none found.
func (m *Http) ValidateAll() error {
return m.validate(true)
}
func (m *Http) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
for idx, item := range m.GetRules() {
_, _ = idx, item
if all {
switch v := interface{}(item).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, HttpValidationError{
field: fmt.Sprintf("Rules[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, HttpValidationError{
field: fmt.Sprintf("Rules[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return HttpValidationError{
field: fmt.Sprintf("Rules[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for FullyDecodeReservedExpansion
if len(errors) > 0 {
return HttpMultiError(errors)
}
return nil
}
// HttpMultiError is an error wrapping multiple validation errors returned by
// Http.ValidateAll() if the designated constraints aren't met.
type HttpMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m HttpMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m HttpMultiError) AllErrors() []error { return m }
// HttpValidationError is the validation error returned by Http.Validate if the
// designated constraints aren't met.
type HttpValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e HttpValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e HttpValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e HttpValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e HttpValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e HttpValidationError) ErrorName() string { return "HttpValidationError" }
// Error satisfies the builtin error interface
func (e HttpValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sHttp.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = HttpValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = HttpValidationError{}
// Validate checks the field values on HttpRule with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *HttpRule) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on HttpRule with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in HttpRuleMultiError, or nil
// if none found.
func (m *HttpRule) ValidateAll() error {
return m.validate(true)
}
func (m *HttpRule) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Selector
// no validation rules for Body
// no validation rules for ResponseBody
for idx, item := range m.GetAdditionalBindings() {
_, _ = idx, item
if all {
switch v := interface{}(item).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, HttpRuleValidationError{
field: fmt.Sprintf("AdditionalBindings[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, HttpRuleValidationError{
field: fmt.Sprintf("AdditionalBindings[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return HttpRuleValidationError{
field: fmt.Sprintf("AdditionalBindings[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
switch m.Pattern.(type) {
case *HttpRule_Get:
// no validation rules for Get
case *HttpRule_Put:
// no validation rules for Put
case *HttpRule_Post:
// no validation rules for Post
case *HttpRule_Delete:
// no validation rules for Delete
case *HttpRule_Patch:
// no validation rules for Patch
case *HttpRule_Custom:
if all {
switch v := interface{}(m.GetCustom()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, HttpRuleValidationError{
field: "Custom",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, HttpRuleValidationError{
field: "Custom",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetCustom()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return HttpRuleValidationError{
field: "Custom",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(errors) > 0 {
return HttpRuleMultiError(errors)
}
return nil
}
// HttpRuleMultiError is an error wrapping multiple validation errors returned
// by HttpRule.ValidateAll() if the designated constraints aren't met.
type HttpRuleMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m HttpRuleMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m HttpRuleMultiError) AllErrors() []error { return m }
// HttpRuleValidationError is the validation error returned by
// HttpRule.Validate if the designated constraints aren't met.
type HttpRuleValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e HttpRuleValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e HttpRuleValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e HttpRuleValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e HttpRuleValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e HttpRuleValidationError) ErrorName() string { return "HttpRuleValidationError" }
// Error satisfies the builtin error interface
func (e HttpRuleValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sHttpRule.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = HttpRuleValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = HttpRuleValidationError{}
// Validate checks the field values on CustomHttpPattern with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
func (m *CustomHttpPattern) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on CustomHttpPattern with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// CustomHttpPatternMultiError, or nil if none found.
func (m *CustomHttpPattern) ValidateAll() error {
return m.validate(true)
}
func (m *CustomHttpPattern) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Kind
// no validation rules for Path
if len(errors) > 0 {
return CustomHttpPatternMultiError(errors)
}
return nil
}
// CustomHttpPatternMultiError is an error wrapping multiple validation errors
// returned by CustomHttpPattern.ValidateAll() if the designated constraints
// aren't met.
type CustomHttpPatternMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m CustomHttpPatternMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m CustomHttpPatternMultiError) AllErrors() []error { return m }
// CustomHttpPatternValidationError is the validation error returned by
// CustomHttpPattern.Validate if the designated constraints aren't met.
type CustomHttpPatternValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CustomHttpPatternValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CustomHttpPatternValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CustomHttpPatternValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CustomHttpPatternValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CustomHttpPatternValidationError) ErrorName() string {
return "CustomHttpPatternValidationError"
}
// Error satisfies the builtin error interface
func (e CustomHttpPatternValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sCustomHttpPattern.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CustomHttpPatternValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CustomHttpPatternValidationError{}