mirror of https://github.com/dragonflyoss/api.git
2245 lines
56 KiB
Go
2245 lines
56 KiB
Go
// Code generated by protoc-gen-validate. DO NOT EDIT.
|
|
// source: pkg/apis/scheduler/v1/scheduler.proto
|
|
|
|
package v1
|
|
|
|
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 PeerTaskRequest 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 *PeerTaskRequest) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on PeerTaskRequest 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
|
|
// PeerTaskRequestMultiError, or nil if none found.
|
|
func (m *PeerTaskRequest) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *PeerTaskRequest) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if uri, err := url.Parse(m.GetUrl()); err != nil {
|
|
err = PeerTaskRequestValidationError{
|
|
field: "Url",
|
|
reason: "value must be a valid URI",
|
|
cause: err,
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
} else if !uri.IsAbs() {
|
|
err := PeerTaskRequestValidationError{
|
|
field: "Url",
|
|
reason: "value must be absolute",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if m.GetUrlMeta() == nil {
|
|
err := PeerTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "value is required",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetUrlMeta()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PeerTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PeerTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PeerTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetPeerId()) < 1 {
|
|
err := PeerTaskRequestValidationError{
|
|
field: "PeerId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetPeerHost()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PeerTaskRequestValidationError{
|
|
field: "PeerHost",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PeerTaskRequestValidationError{
|
|
field: "PeerHost",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PeerTaskRequestValidationError{
|
|
field: "PeerHost",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetHostLoad()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PeerTaskRequestValidationError{
|
|
field: "HostLoad",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PeerTaskRequestValidationError{
|
|
field: "HostLoad",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetHostLoad()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PeerTaskRequestValidationError{
|
|
field: "HostLoad",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
// no validation rules for IsMigrating
|
|
|
|
// no validation rules for Pattern
|
|
|
|
// no validation rules for TaskId
|
|
|
|
if len(errors) > 0 {
|
|
return PeerTaskRequestMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PeerTaskRequestMultiError is an error wrapping multiple validation errors
|
|
// returned by PeerTaskRequest.ValidateAll() if the designated constraints
|
|
// aren't met.
|
|
type PeerTaskRequestMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m PeerTaskRequestMultiError) 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 PeerTaskRequestMultiError) AllErrors() []error { return m }
|
|
|
|
// PeerTaskRequestValidationError is the validation error returned by
|
|
// PeerTaskRequest.Validate if the designated constraints aren't met.
|
|
type PeerTaskRequestValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e PeerTaskRequestValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e PeerTaskRequestValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e PeerTaskRequestValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e PeerTaskRequestValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e PeerTaskRequestValidationError) ErrorName() string { return "PeerTaskRequestValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e PeerTaskRequestValidationError) 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 %sPeerTaskRequest.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = PeerTaskRequestValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = PeerTaskRequestValidationError{}
|
|
|
|
// Validate checks the field values on RegisterResult 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 *RegisterResult) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on RegisterResult 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 RegisterResultMultiError,
|
|
// or nil if none found.
|
|
func (m *RegisterResult) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *RegisterResult) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
// no validation rules for TaskType
|
|
|
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
|
err := RegisterResultValidationError{
|
|
field: "TaskId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
// no validation rules for SizeScope
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetExtendAttribute()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, RegisterResultValidationError{
|
|
field: "ExtendAttribute",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, RegisterResultValidationError{
|
|
field: "ExtendAttribute",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return RegisterResultValidationError{
|
|
field: "ExtendAttribute",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
switch m.DirectPiece.(type) {
|
|
|
|
case *RegisterResult_SinglePiece:
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetSinglePiece()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, RegisterResultValidationError{
|
|
field: "SinglePiece",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, RegisterResultValidationError{
|
|
field: "SinglePiece",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetSinglePiece()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return RegisterResultValidationError{
|
|
field: "SinglePiece",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
case *RegisterResult_PieceContent:
|
|
// no validation rules for PieceContent
|
|
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return RegisterResultMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// RegisterResultMultiError is an error wrapping multiple validation errors
|
|
// returned by RegisterResult.ValidateAll() if the designated constraints
|
|
// aren't met.
|
|
type RegisterResultMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m RegisterResultMultiError) 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 RegisterResultMultiError) AllErrors() []error { return m }
|
|
|
|
// RegisterResultValidationError is the validation error returned by
|
|
// RegisterResult.Validate if the designated constraints aren't met.
|
|
type RegisterResultValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e RegisterResultValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e RegisterResultValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e RegisterResultValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e RegisterResultValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e RegisterResultValidationError) ErrorName() string { return "RegisterResultValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e RegisterResultValidationError) 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 %sRegisterResult.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = RegisterResultValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = RegisterResultValidationError{}
|
|
|
|
// Validate checks the field values on SinglePiece 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 *SinglePiece) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on SinglePiece 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 SinglePieceMultiError, or
|
|
// nil if none found.
|
|
func (m *SinglePiece) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *SinglePiece) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetDstPid()) < 1 {
|
|
err := SinglePieceValidationError{
|
|
field: "DstPid",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetDstAddr()) < 1 {
|
|
err := SinglePieceValidationError{
|
|
field: "DstAddr",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetPieceInfo()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, SinglePieceValidationError{
|
|
field: "PieceInfo",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, SinglePieceValidationError{
|
|
field: "PieceInfo",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return SinglePieceValidationError{
|
|
field: "PieceInfo",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return SinglePieceMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// SinglePieceMultiError is an error wrapping multiple validation errors
|
|
// returned by SinglePiece.ValidateAll() if the designated constraints aren't met.
|
|
type SinglePieceMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m SinglePieceMultiError) 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 SinglePieceMultiError) AllErrors() []error { return m }
|
|
|
|
// SinglePieceValidationError is the validation error returned by
|
|
// SinglePiece.Validate if the designated constraints aren't met.
|
|
type SinglePieceValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e SinglePieceValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e SinglePieceValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e SinglePieceValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e SinglePieceValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e SinglePieceValidationError) ErrorName() string { return "SinglePieceValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e SinglePieceValidationError) 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 %sSinglePiece.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = SinglePieceValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = SinglePieceValidationError{}
|
|
|
|
// Validate checks the field values on PeerHost 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 *PeerHost) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on PeerHost 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 PeerHostMultiError, or nil
|
|
// if none found.
|
|
func (m *PeerHost) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *PeerHost) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetId()) < 1 {
|
|
err := PeerHostValidationError{
|
|
field: "Id",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if ip := net.ParseIP(m.GetIp()); ip == nil {
|
|
err := PeerHostValidationError{
|
|
field: "Ip",
|
|
reason: "value must be a valid IP address",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if val := m.GetRpcPort(); val < 1024 || val >= 65535 {
|
|
err := PeerHostValidationError{
|
|
field: "RpcPort",
|
|
reason: "value must be inside range [1024, 65535)",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if val := m.GetDownPort(); val < 1024 || val >= 65535 {
|
|
err := PeerHostValidationError{
|
|
field: "DownPort",
|
|
reason: "value must be inside range [1024, 65535)",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if err := m._validateHostname(m.GetHostName()); err != nil {
|
|
err = PeerHostValidationError{
|
|
field: "HostName",
|
|
reason: "value must be a valid hostname",
|
|
cause: err,
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
// no validation rules for SecurityDomain
|
|
|
|
// no validation rules for Location
|
|
|
|
// no validation rules for Idc
|
|
|
|
// no validation rules for NetTopology
|
|
|
|
if len(errors) > 0 {
|
|
return PeerHostMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *PeerHost) _validateHostname(host string) error {
|
|
s := strings.ToLower(strings.TrimSuffix(host, "."))
|
|
|
|
if len(host) > 253 {
|
|
return errors.New("hostname cannot exceed 253 characters")
|
|
}
|
|
|
|
for _, part := range strings.Split(s, ".") {
|
|
if l := len(part); l == 0 || l > 63 {
|
|
return errors.New("hostname part must be non-empty and cannot exceed 63 characters")
|
|
}
|
|
|
|
if part[0] == '-' {
|
|
return errors.New("hostname parts cannot begin with hyphens")
|
|
}
|
|
|
|
if part[len(part)-1] == '-' {
|
|
return errors.New("hostname parts cannot end with hyphens")
|
|
}
|
|
|
|
for _, r := range part {
|
|
if (r < 'a' || r > 'z') && (r < '0' || r > '9') && r != '-' {
|
|
return fmt.Errorf("hostname parts can only contain alphanumeric characters or hyphens, got %q", string(r))
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PeerHostMultiError is an error wrapping multiple validation errors returned
|
|
// by PeerHost.ValidateAll() if the designated constraints aren't met.
|
|
type PeerHostMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m PeerHostMultiError) 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 PeerHostMultiError) AllErrors() []error { return m }
|
|
|
|
// PeerHostValidationError is the validation error returned by
|
|
// PeerHost.Validate if the designated constraints aren't met.
|
|
type PeerHostValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e PeerHostValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e PeerHostValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e PeerHostValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e PeerHostValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e PeerHostValidationError) ErrorName() string { return "PeerHostValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e PeerHostValidationError) 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 %sPeerHost.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = PeerHostValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = PeerHostValidationError{}
|
|
|
|
// Validate checks the field values on PieceResult 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 *PieceResult) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on PieceResult 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 PieceResultMultiError, or
|
|
// nil if none found.
|
|
func (m *PieceResult) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *PieceResult) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
|
err := PieceResultValidationError{
|
|
field: "TaskId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetSrcPid()) < 1 {
|
|
err := PieceResultValidationError{
|
|
field: "SrcPid",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
// no validation rules for DstPid
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetPieceInfo()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PieceResultValidationError{
|
|
field: "PieceInfo",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PieceResultValidationError{
|
|
field: "PieceInfo",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PieceResultValidationError{
|
|
field: "PieceInfo",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
// no validation rules for BeginTime
|
|
|
|
// no validation rules for EndTime
|
|
|
|
// no validation rules for Success
|
|
|
|
// no validation rules for Code
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetHostLoad()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PieceResultValidationError{
|
|
field: "HostLoad",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PieceResultValidationError{
|
|
field: "HostLoad",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetHostLoad()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PieceResultValidationError{
|
|
field: "HostLoad",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
// no validation rules for FinishedCount
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetExtendAttribute()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PieceResultValidationError{
|
|
field: "ExtendAttribute",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PieceResultValidationError{
|
|
field: "ExtendAttribute",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PieceResultValidationError{
|
|
field: "ExtendAttribute",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return PieceResultMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PieceResultMultiError is an error wrapping multiple validation errors
|
|
// returned by PieceResult.ValidateAll() if the designated constraints aren't met.
|
|
type PieceResultMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m PieceResultMultiError) 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 PieceResultMultiError) AllErrors() []error { return m }
|
|
|
|
// PieceResultValidationError is the validation error returned by
|
|
// PieceResult.Validate if the designated constraints aren't met.
|
|
type PieceResultValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e PieceResultValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e PieceResultValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e PieceResultValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e PieceResultValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e PieceResultValidationError) ErrorName() string { return "PieceResultValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e PieceResultValidationError) 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 %sPieceResult.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = PieceResultValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = PieceResultValidationError{}
|
|
|
|
// Validate checks the field values on PeerPacket 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 *PeerPacket) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on PeerPacket 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 PeerPacketMultiError, or
|
|
// nil if none found.
|
|
func (m *PeerPacket) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *PeerPacket) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
|
err := PeerPacketValidationError{
|
|
field: "TaskId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetSrcPid()) < 1 {
|
|
err := PeerPacketValidationError{
|
|
field: "SrcPid",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if m.GetParallelCount() < 1 {
|
|
err := PeerPacketValidationError{
|
|
field: "ParallelCount",
|
|
reason: "value must be greater than or equal to 1",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetMainPeer()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PeerPacketValidationError{
|
|
field: "MainPeer",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PeerPacketValidationError{
|
|
field: "MainPeer",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetMainPeer()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PeerPacketValidationError{
|
|
field: "MainPeer",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
for idx, item := range m.GetCandidatePeers() {
|
|
_, _ = idx, item
|
|
|
|
if all {
|
|
switch v := interface{}(item).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PeerPacketValidationError{
|
|
field: fmt.Sprintf("CandidatePeers[%v]", idx),
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PeerPacketValidationError{
|
|
field: fmt.Sprintf("CandidatePeers[%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 PeerPacketValidationError{
|
|
field: fmt.Sprintf("CandidatePeers[%v]", idx),
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// no validation rules for Code
|
|
|
|
switch m.Errordetails.(type) {
|
|
|
|
case *PeerPacket_SourceError:
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetSourceError()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PeerPacketValidationError{
|
|
field: "SourceError",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PeerPacketValidationError{
|
|
field: "SourceError",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetSourceError()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PeerPacketValidationError{
|
|
field: "SourceError",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return PeerPacketMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PeerPacketMultiError is an error wrapping multiple validation errors
|
|
// returned by PeerPacket.ValidateAll() if the designated constraints aren't met.
|
|
type PeerPacketMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m PeerPacketMultiError) 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 PeerPacketMultiError) AllErrors() []error { return m }
|
|
|
|
// PeerPacketValidationError is the validation error returned by
|
|
// PeerPacket.Validate if the designated constraints aren't met.
|
|
type PeerPacketValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e PeerPacketValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e PeerPacketValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e PeerPacketValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e PeerPacketValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e PeerPacketValidationError) ErrorName() string { return "PeerPacketValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e PeerPacketValidationError) 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 %sPeerPacket.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = PeerPacketValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = PeerPacketValidationError{}
|
|
|
|
// Validate checks the field values on PeerResult 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 *PeerResult) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on PeerResult 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 PeerResultMultiError, or
|
|
// nil if none found.
|
|
func (m *PeerResult) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *PeerResult) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
|
err := PeerResultValidationError{
|
|
field: "TaskId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetPeerId()) < 1 {
|
|
err := PeerResultValidationError{
|
|
field: "PeerId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if ip := net.ParseIP(m.GetSrcIp()); ip == nil {
|
|
err := PeerResultValidationError{
|
|
field: "SrcIp",
|
|
reason: "value must be a valid IP address",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
// no validation rules for SecurityDomain
|
|
|
|
// no validation rules for Idc
|
|
|
|
if uri, err := url.Parse(m.GetUrl()); err != nil {
|
|
err = PeerResultValidationError{
|
|
field: "Url",
|
|
reason: "value must be a valid URI",
|
|
cause: err,
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
} else if !uri.IsAbs() {
|
|
err := PeerResultValidationError{
|
|
field: "Url",
|
|
reason: "value must be absolute",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if m.GetContentLength() < -1 {
|
|
err := PeerResultValidationError{
|
|
field: "ContentLength",
|
|
reason: "value must be greater than or equal to -1",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
// no validation rules for Traffic
|
|
|
|
// no validation rules for Cost
|
|
|
|
// no validation rules for Success
|
|
|
|
// no validation rules for Code
|
|
|
|
if m.GetTotalPieceCount() < -1 {
|
|
err := PeerResultValidationError{
|
|
field: "TotalPieceCount",
|
|
reason: "value must be greater than or equal to -1",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
switch m.Errordetails.(type) {
|
|
|
|
case *PeerResult_SourceError:
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetSourceError()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, PeerResultValidationError{
|
|
field: "SourceError",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, PeerResultValidationError{
|
|
field: "SourceError",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetSourceError()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return PeerResultValidationError{
|
|
field: "SourceError",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return PeerResultMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PeerResultMultiError is an error wrapping multiple validation errors
|
|
// returned by PeerResult.ValidateAll() if the designated constraints aren't met.
|
|
type PeerResultMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m PeerResultMultiError) 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 PeerResultMultiError) AllErrors() []error { return m }
|
|
|
|
// PeerResultValidationError is the validation error returned by
|
|
// PeerResult.Validate if the designated constraints aren't met.
|
|
type PeerResultValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e PeerResultValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e PeerResultValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e PeerResultValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e PeerResultValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e PeerResultValidationError) ErrorName() string { return "PeerResultValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e PeerResultValidationError) 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 %sPeerResult.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = PeerResultValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = PeerResultValidationError{}
|
|
|
|
// Validate checks the field values on PeerTarget 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 *PeerTarget) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on PeerTarget 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 PeerTargetMultiError, or
|
|
// nil if none found.
|
|
func (m *PeerTarget) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *PeerTarget) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
|
err := PeerTargetValidationError{
|
|
field: "TaskId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetPeerId()) < 1 {
|
|
err := PeerTargetValidationError{
|
|
field: "PeerId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return PeerTargetMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PeerTargetMultiError is an error wrapping multiple validation errors
|
|
// returned by PeerTarget.ValidateAll() if the designated constraints aren't met.
|
|
type PeerTargetMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m PeerTargetMultiError) 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 PeerTargetMultiError) AllErrors() []error { return m }
|
|
|
|
// PeerTargetValidationError is the validation error returned by
|
|
// PeerTarget.Validate if the designated constraints aren't met.
|
|
type PeerTargetValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e PeerTargetValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e PeerTargetValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e PeerTargetValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e PeerTargetValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e PeerTargetValidationError) ErrorName() string { return "PeerTargetValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e PeerTargetValidationError) 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 %sPeerTarget.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = PeerTargetValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = PeerTargetValidationError{}
|
|
|
|
// Validate checks the field values on StatTaskRequest 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 *StatTaskRequest) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on StatTaskRequest 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
|
|
// StatTaskRequestMultiError, or nil if none found.
|
|
func (m *StatTaskRequest) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *StatTaskRequest) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
|
err := StatTaskRequestValidationError{
|
|
field: "TaskId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return StatTaskRequestMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// StatTaskRequestMultiError is an error wrapping multiple validation errors
|
|
// returned by StatTaskRequest.ValidateAll() if the designated constraints
|
|
// aren't met.
|
|
type StatTaskRequestMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m StatTaskRequestMultiError) 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 StatTaskRequestMultiError) AllErrors() []error { return m }
|
|
|
|
// StatTaskRequestValidationError is the validation error returned by
|
|
// StatTaskRequest.Validate if the designated constraints aren't met.
|
|
type StatTaskRequestValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e StatTaskRequestValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e StatTaskRequestValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e StatTaskRequestValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e StatTaskRequestValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e StatTaskRequestValidationError) ErrorName() string { return "StatTaskRequestValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e StatTaskRequestValidationError) 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 %sStatTaskRequest.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = StatTaskRequestValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = StatTaskRequestValidationError{}
|
|
|
|
// Validate checks the field values on Task 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 *Task) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on Task 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 TaskMultiError, or nil if none found.
|
|
func (m *Task) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *Task) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetId()) < 1 {
|
|
err := TaskValidationError{
|
|
field: "Id",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
// no validation rules for Type
|
|
|
|
if m.GetContentLength() < 1 {
|
|
err := TaskValidationError{
|
|
field: "ContentLength",
|
|
reason: "value must be greater than or equal to 1",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if m.GetTotalPieceCount() < 1 {
|
|
err := TaskValidationError{
|
|
field: "TotalPieceCount",
|
|
reason: "value must be greater than or equal to 1",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetState()) < 1 {
|
|
err := TaskValidationError{
|
|
field: "State",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if m.GetPeerCount() < 0 {
|
|
err := TaskValidationError{
|
|
field: "PeerCount",
|
|
reason: "value must be greater than or equal to 0",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
// no validation rules for HasAvailablePeer
|
|
|
|
if len(errors) > 0 {
|
|
return TaskMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// TaskMultiError is an error wrapping multiple validation errors returned by
|
|
// Task.ValidateAll() if the designated constraints aren't met.
|
|
type TaskMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m TaskMultiError) 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 TaskMultiError) AllErrors() []error { return m }
|
|
|
|
// TaskValidationError is the validation error returned by Task.Validate if the
|
|
// designated constraints aren't met.
|
|
type TaskValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e TaskValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e TaskValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e TaskValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e TaskValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e TaskValidationError) ErrorName() string { return "TaskValidationError" }
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e TaskValidationError) 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 %sTask.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = TaskValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = TaskValidationError{}
|
|
|
|
// Validate checks the field values on AnnounceTaskRequest 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 *AnnounceTaskRequest) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on AnnounceTaskRequest 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
|
|
// AnnounceTaskRequestMultiError, or nil if none found.
|
|
func (m *AnnounceTaskRequest) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *AnnounceTaskRequest) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
|
|
err := AnnounceTaskRequestValidationError{
|
|
field: "TaskId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if m.GetUrl() != "" {
|
|
|
|
if uri, err := url.Parse(m.GetUrl()); err != nil {
|
|
err = AnnounceTaskRequestValidationError{
|
|
field: "Url",
|
|
reason: "value must be a valid URI",
|
|
cause: err,
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
} else if !uri.IsAbs() {
|
|
err := AnnounceTaskRequestValidationError{
|
|
field: "Url",
|
|
reason: "value must be absolute",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
}
|
|
|
|
if m.GetUrlMeta() == nil {
|
|
err := AnnounceTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "value is required",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetUrlMeta()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return AnnounceTaskRequestValidationError{
|
|
field: "UrlMeta",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetPeerHost()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
field: "PeerHost",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
field: "PeerHost",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return AnnounceTaskRequestValidationError{
|
|
field: "PeerHost",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
if m.GetPiecePacket() == nil {
|
|
err := AnnounceTaskRequestValidationError{
|
|
field: "PiecePacket",
|
|
reason: "value is required",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if all {
|
|
switch v := interface{}(m.GetPiecePacket()).(type) {
|
|
case interface{ ValidateAll() error }:
|
|
if err := v.ValidateAll(); err != nil {
|
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
field: "PiecePacket",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
case interface{ Validate() error }:
|
|
if err := v.Validate(); err != nil {
|
|
errors = append(errors, AnnounceTaskRequestValidationError{
|
|
field: "PiecePacket",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
})
|
|
}
|
|
}
|
|
} else if v, ok := interface{}(m.GetPiecePacket()).(interface{ Validate() error }); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return AnnounceTaskRequestValidationError{
|
|
field: "PiecePacket",
|
|
reason: "embedded message failed validation",
|
|
cause: err,
|
|
}
|
|
}
|
|
}
|
|
|
|
// no validation rules for TaskType
|
|
|
|
if len(errors) > 0 {
|
|
return AnnounceTaskRequestMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// AnnounceTaskRequestMultiError is an error wrapping multiple validation
|
|
// errors returned by AnnounceTaskRequest.ValidateAll() if the designated
|
|
// constraints aren't met.
|
|
type AnnounceTaskRequestMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m AnnounceTaskRequestMultiError) 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 AnnounceTaskRequestMultiError) AllErrors() []error { return m }
|
|
|
|
// AnnounceTaskRequestValidationError is the validation error returned by
|
|
// AnnounceTaskRequest.Validate if the designated constraints aren't met.
|
|
type AnnounceTaskRequestValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e AnnounceTaskRequestValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e AnnounceTaskRequestValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e AnnounceTaskRequestValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e AnnounceTaskRequestValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e AnnounceTaskRequestValidationError) ErrorName() string {
|
|
return "AnnounceTaskRequestValidationError"
|
|
}
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e AnnounceTaskRequestValidationError) 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 %sAnnounceTaskRequest.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = AnnounceTaskRequestValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = AnnounceTaskRequestValidationError{}
|
|
|
|
// Validate checks the field values on PeerPacket_DestPeer 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 *PeerPacket_DestPeer) Validate() error {
|
|
return m.validate(false)
|
|
}
|
|
|
|
// ValidateAll checks the field values on PeerPacket_DestPeer 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
|
|
// PeerPacket_DestPeerMultiError, or nil if none found.
|
|
func (m *PeerPacket_DestPeer) ValidateAll() error {
|
|
return m.validate(true)
|
|
}
|
|
|
|
func (m *PeerPacket_DestPeer) validate(all bool) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
var errors []error
|
|
|
|
if ip := net.ParseIP(m.GetIp()); ip == nil {
|
|
err := PeerPacket_DestPeerValidationError{
|
|
field: "Ip",
|
|
reason: "value must be a valid IP address",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if val := m.GetRpcPort(); val < 1024 || val >= 65535 {
|
|
err := PeerPacket_DestPeerValidationError{
|
|
field: "RpcPort",
|
|
reason: "value must be inside range [1024, 65535)",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if utf8.RuneCountInString(m.GetPeerId()) < 1 {
|
|
err := PeerPacket_DestPeerValidationError{
|
|
field: "PeerId",
|
|
reason: "value length must be at least 1 runes",
|
|
}
|
|
if !all {
|
|
return err
|
|
}
|
|
errors = append(errors, err)
|
|
}
|
|
|
|
if len(errors) > 0 {
|
|
return PeerPacket_DestPeerMultiError(errors)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PeerPacket_DestPeerMultiError is an error wrapping multiple validation
|
|
// errors returned by PeerPacket_DestPeer.ValidateAll() if the designated
|
|
// constraints aren't met.
|
|
type PeerPacket_DestPeerMultiError []error
|
|
|
|
// Error returns a concatenation of all the error messages it wraps.
|
|
func (m PeerPacket_DestPeerMultiError) 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 PeerPacket_DestPeerMultiError) AllErrors() []error { return m }
|
|
|
|
// PeerPacket_DestPeerValidationError is the validation error returned by
|
|
// PeerPacket_DestPeer.Validate if the designated constraints aren't met.
|
|
type PeerPacket_DestPeerValidationError struct {
|
|
field string
|
|
reason string
|
|
cause error
|
|
key bool
|
|
}
|
|
|
|
// Field function returns field value.
|
|
func (e PeerPacket_DestPeerValidationError) Field() string { return e.field }
|
|
|
|
// Reason function returns reason value.
|
|
func (e PeerPacket_DestPeerValidationError) Reason() string { return e.reason }
|
|
|
|
// Cause function returns cause value.
|
|
func (e PeerPacket_DestPeerValidationError) Cause() error { return e.cause }
|
|
|
|
// Key function returns key value.
|
|
func (e PeerPacket_DestPeerValidationError) Key() bool { return e.key }
|
|
|
|
// ErrorName returns error name.
|
|
func (e PeerPacket_DestPeerValidationError) ErrorName() string {
|
|
return "PeerPacket_DestPeerValidationError"
|
|
}
|
|
|
|
// Error satisfies the builtin error interface
|
|
func (e PeerPacket_DestPeerValidationError) 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 %sPeerPacket_DestPeer.%s: %s%s",
|
|
key,
|
|
e.field,
|
|
e.reason,
|
|
cause)
|
|
}
|
|
|
|
var _ error = PeerPacket_DestPeerValidationError{}
|
|
|
|
var _ interface {
|
|
Field() string
|
|
Reason() string
|
|
Key() bool
|
|
Cause() error
|
|
ErrorName() string
|
|
} = PeerPacket_DestPeerValidationError{}
|