// Code generated by protoc-gen-validate. DO NOT EDIT. // source: google/protobuf/api.proto package apipb 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 Api 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 *Api) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Api 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 ApiMultiError, or nil if none found. func (m *Api) ValidateAll() error { return m.validate(true) } func (m *Api) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Name for idx, item := range m.GetMethods() { _, _ = idx, item if all { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ApiValidationError{ field: fmt.Sprintf("Methods[%v]", idx), reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ApiValidationError{ field: fmt.Sprintf("Methods[%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 ApiValidationError{ field: fmt.Sprintf("Methods[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } for idx, item := range m.GetOptions() { _, _ = idx, item if all { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ApiValidationError{ field: fmt.Sprintf("Options[%v]", idx), reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ApiValidationError{ field: fmt.Sprintf("Options[%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 ApiValidationError{ field: fmt.Sprintf("Options[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } // no validation rules for Version if all { switch v := interface{}(m.GetSourceContext()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ApiValidationError{ field: "SourceContext", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ApiValidationError{ field: "SourceContext", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetSourceContext()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ApiValidationError{ field: "SourceContext", reason: "embedded message failed validation", cause: err, } } } for idx, item := range m.GetMixins() { _, _ = idx, item if all { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ApiValidationError{ field: fmt.Sprintf("Mixins[%v]", idx), reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ApiValidationError{ field: fmt.Sprintf("Mixins[%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 ApiValidationError{ field: fmt.Sprintf("Mixins[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } // no validation rules for Syntax if len(errors) > 0 { return ApiMultiError(errors) } return nil } // ApiMultiError is an error wrapping multiple validation errors returned by // Api.ValidateAll() if the designated constraints aren't met. type ApiMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ApiMultiError) 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 ApiMultiError) AllErrors() []error { return m } // ApiValidationError is the validation error returned by Api.Validate if the // designated constraints aren't met. type ApiValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e ApiValidationError) Field() string { return e.field } // Reason function returns reason value. func (e ApiValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e ApiValidationError) Cause() error { return e.cause } // Key function returns key value. func (e ApiValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e ApiValidationError) ErrorName() string { return "ApiValidationError" } // Error satisfies the builtin error interface func (e ApiValidationError) 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 %sApi.%s: %s%s", key, e.field, e.reason, cause) } var _ error = ApiValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = ApiValidationError{} // Validate checks the field values on Method 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 *Method) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Method 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 MethodMultiError, or nil if none found. func (m *Method) ValidateAll() error { return m.validate(true) } func (m *Method) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Name // no validation rules for RequestTypeUrl // no validation rules for RequestStreaming // no validation rules for ResponseTypeUrl // no validation rules for ResponseStreaming for idx, item := range m.GetOptions() { _, _ = idx, item if all { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, MethodValidationError{ field: fmt.Sprintf("Options[%v]", idx), reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, MethodValidationError{ field: fmt.Sprintf("Options[%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 MethodValidationError{ field: fmt.Sprintf("Options[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } // no validation rules for Syntax if len(errors) > 0 { return MethodMultiError(errors) } return nil } // MethodMultiError is an error wrapping multiple validation errors returned by // Method.ValidateAll() if the designated constraints aren't met. type MethodMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m MethodMultiError) 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 MethodMultiError) AllErrors() []error { return m } // MethodValidationError is the validation error returned by Method.Validate if // the designated constraints aren't met. type MethodValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e MethodValidationError) Field() string { return e.field } // Reason function returns reason value. func (e MethodValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e MethodValidationError) Cause() error { return e.cause } // Key function returns key value. func (e MethodValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e MethodValidationError) ErrorName() string { return "MethodValidationError" } // Error satisfies the builtin error interface func (e MethodValidationError) 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 %sMethod.%s: %s%s", key, e.field, e.reason, cause) } var _ error = MethodValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = MethodValidationError{} // Validate checks the field values on Mixin 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 *Mixin) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Mixin 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 MixinMultiError, or nil if none found. func (m *Mixin) ValidateAll() error { return m.validate(true) } func (m *Mixin) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Name // no validation rules for Root if len(errors) > 0 { return MixinMultiError(errors) } return nil } // MixinMultiError is an error wrapping multiple validation errors returned by // Mixin.ValidateAll() if the designated constraints aren't met. type MixinMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m MixinMultiError) 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 MixinMultiError) AllErrors() []error { return m } // MixinValidationError is the validation error returned by Mixin.Validate if // the designated constraints aren't met. type MixinValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e MixinValidationError) Field() string { return e.field } // Reason function returns reason value. func (e MixinValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e MixinValidationError) Cause() error { return e.cause } // Key function returns key value. func (e MixinValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e MixinValidationError) ErrorName() string { return "MixinValidationError" } // Error satisfies the builtin error interface func (e MixinValidationError) 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 %sMixin.%s: %s%s", key, e.field, e.reason, cause) } var _ error = MixinValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = MixinValidationError{}