api/pkg/apis/scheduler/v1/scheduler.pb.validate.go

3556 lines
87 KiB
Go

// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: pkg/apis/scheduler/v1/scheduler.proto
package scheduler
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"sort"
"strings"
"time"
"unicode/utf8"
"google.golang.org/protobuf/types/known/anypb"
common "d7y.io/api/v2/pkg/apis/common/v1"
)
// 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
_ = common.TaskType(0)
)
// 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,
}
}
}
// no validation rules for Prefetch
// no validation rules for IsMigrating
// 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 v := m.DirectPiece.(type) {
case *RegisterResult_SinglePiece:
if v == nil {
err := RegisterResultValidationError{
field: "DirectPiece",
reason: "oneof value cannot be a typed-nil",
}
if !all {
return err
}
errors = append(errors, err)
}
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:
if v == nil {
err := RegisterResultValidationError{
field: "DirectPiece",
reason: "oneof value cannot be a typed-nil",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for PieceContent
default:
_ = v // ensures v is used
}
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 Location
// no validation rules for Idc
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
// 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 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 v := m.Errordetails.(type) {
case *PeerPacket_SourceError:
if v == nil {
err := PeerPacketValidationError{
field: "Errordetails",
reason: "oneof value cannot be a typed-nil",
}
if !all {
return err
}
errors = append(errors, err)
}
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,
}
}
}
default:
_ = v // ensures v is used
}
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 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 v := m.Errordetails.(type) {
case *PeerResult_SourceError:
if v == nil {
err := PeerResultValidationError{
field: "Errordetails",
reason: "oneof value cannot be a typed-nil",
}
if !all {
return err
}
errors = append(errors, err)
}
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,
}
}
}
default:
_ = v // ensures v is used
}
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 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 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 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 LeaveHostRequest 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 *LeaveHostRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on LeaveHostRequest 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
// LeaveHostRequestMultiError, or nil if none found.
func (m *LeaveHostRequest) ValidateAll() error {
return m.validate(true)
}
func (m *LeaveHostRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if utf8.RuneCountInString(m.GetId()) < 1 {
err := LeaveHostRequestValidationError{
field: "Id",
reason: "value length must be at least 1 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return LeaveHostRequestMultiError(errors)
}
return nil
}
// LeaveHostRequestMultiError is an error wrapping multiple validation errors
// returned by LeaveHostRequest.ValidateAll() if the designated constraints
// aren't met.
type LeaveHostRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m LeaveHostRequestMultiError) 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 LeaveHostRequestMultiError) AllErrors() []error { return m }
// LeaveHostRequestValidationError is the validation error returned by
// LeaveHostRequest.Validate if the designated constraints aren't met.
type LeaveHostRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e LeaveHostRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e LeaveHostRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e LeaveHostRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e LeaveHostRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e LeaveHostRequestValidationError) ErrorName() string { return "LeaveHostRequestValidationError" }
// Error satisfies the builtin error interface
func (e LeaveHostRequestValidationError) 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 %sLeaveHostRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = LeaveHostRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = LeaveHostRequestValidationError{}
// Validate checks the field values on AnnounceHostRequest 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 *AnnounceHostRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on AnnounceHostRequest 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
// AnnounceHostRequestMultiError, or nil if none found.
func (m *AnnounceHostRequest) ValidateAll() error {
return m.validate(true)
}
func (m *AnnounceHostRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if utf8.RuneCountInString(m.GetId()) < 1 {
err := AnnounceHostRequestValidationError{
field: "Id",
reason: "value length must be at least 1 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if _, ok := _AnnounceHostRequest_Type_InLookup[m.GetType()]; !ok {
err := AnnounceHostRequestValidationError{
field: "Type",
reason: "value must be in list [normal super strong weak]",
}
if !all {
return err
}
errors = append(errors, err)
}
if utf8.RuneCountInString(m.GetHostname()) < 1 {
err := AnnounceHostRequestValidationError{
field: "Hostname",
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 := AnnounceHostRequestValidationError{
field: "Ip",
reason: "value must be a valid IP address",
}
if !all {
return err
}
errors = append(errors, err)
}
if val := m.GetPort(); val < 1024 || val >= 65535 {
err := AnnounceHostRequestValidationError{
field: "Port",
reason: "value must be inside range [1024, 65535)",
}
if !all {
return err
}
errors = append(errors, err)
}
if val := m.GetDownloadPort(); val < 1024 || val >= 65535 {
err := AnnounceHostRequestValidationError{
field: "DownloadPort",
reason: "value must be inside range [1024, 65535)",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for Os
// no validation rules for Platform
// no validation rules for PlatformFamily
// no validation rules for PlatformVersion
// no validation rules for KernelVersion
if m.GetCpu() == nil {
err := AnnounceHostRequestValidationError{
field: "Cpu",
reason: "value is required",
}
if !all {
return err
}
errors = append(errors, err)
}
if all {
switch v := interface{}(m.GetCpu()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Cpu",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Cpu",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetCpu()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AnnounceHostRequestValidationError{
field: "Cpu",
reason: "embedded message failed validation",
cause: err,
}
}
}
if m.GetMemory() == nil {
err := AnnounceHostRequestValidationError{
field: "Memory",
reason: "value is required",
}
if !all {
return err
}
errors = append(errors, err)
}
if all {
switch v := interface{}(m.GetMemory()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Memory",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Memory",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetMemory()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AnnounceHostRequestValidationError{
field: "Memory",
reason: "embedded message failed validation",
cause: err,
}
}
}
if m.GetNetwork() == nil {
err := AnnounceHostRequestValidationError{
field: "Network",
reason: "value is required",
}
if !all {
return err
}
errors = append(errors, err)
}
if all {
switch v := interface{}(m.GetNetwork()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Network",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Network",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetNetwork()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AnnounceHostRequestValidationError{
field: "Network",
reason: "embedded message failed validation",
cause: err,
}
}
}
if m.GetDisk() == nil {
err := AnnounceHostRequestValidationError{
field: "Disk",
reason: "value is required",
}
if !all {
return err
}
errors = append(errors, err)
}
if all {
switch v := interface{}(m.GetDisk()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Disk",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Disk",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetDisk()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AnnounceHostRequestValidationError{
field: "Disk",
reason: "embedded message failed validation",
cause: err,
}
}
}
if m.GetBuild() == nil {
err := AnnounceHostRequestValidationError{
field: "Build",
reason: "value is required",
}
if !all {
return err
}
errors = append(errors, err)
}
if all {
switch v := interface{}(m.GetBuild()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Build",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, AnnounceHostRequestValidationError{
field: "Build",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetBuild()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AnnounceHostRequestValidationError{
field: "Build",
reason: "embedded message failed validation",
cause: err,
}
}
}
// no validation rules for SchedulerClusterId
if m.GetObjectStoragePort() != 0 {
if val := m.GetObjectStoragePort(); val < 1024 || val >= 65535 {
err := AnnounceHostRequestValidationError{
field: "ObjectStoragePort",
reason: "value must be inside range [1024, 65535)",
}
if !all {
return err
}
errors = append(errors, err)
}
}
if len(errors) > 0 {
return AnnounceHostRequestMultiError(errors)
}
return nil
}
// AnnounceHostRequestMultiError is an error wrapping multiple validation
// errors returned by AnnounceHostRequest.ValidateAll() if the designated
// constraints aren't met.
type AnnounceHostRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m AnnounceHostRequestMultiError) 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 AnnounceHostRequestMultiError) AllErrors() []error { return m }
// AnnounceHostRequestValidationError is the validation error returned by
// AnnounceHostRequest.Validate if the designated constraints aren't met.
type AnnounceHostRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e AnnounceHostRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e AnnounceHostRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e AnnounceHostRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e AnnounceHostRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e AnnounceHostRequestValidationError) ErrorName() string {
return "AnnounceHostRequestValidationError"
}
// Error satisfies the builtin error interface
func (e AnnounceHostRequestValidationError) 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 %sAnnounceHostRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = AnnounceHostRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = AnnounceHostRequestValidationError{}
var _AnnounceHostRequest_Type_InLookup = map[string]struct{}{
"normal": {},
"super": {},
"strong": {},
"weak": {},
}
// Validate checks the field values on CPU 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 *CPU) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on CPU 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 CPUMultiError, or nil if none found.
func (m *CPU) ValidateAll() error {
return m.validate(true)
}
func (m *CPU) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for LogicalCount
// no validation rules for PhysicalCount
if m.GetPercent() < 0 {
err := CPUValidationError{
field: "Percent",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetProcessPercent() < 0 {
err := CPUValidationError{
field: "ProcessPercent",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetTimes() == nil {
err := CPUValidationError{
field: "Times",
reason: "value is required",
}
if !all {
return err
}
errors = append(errors, err)
}
if all {
switch v := interface{}(m.GetTimes()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, CPUValidationError{
field: "Times",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, CPUValidationError{
field: "Times",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetTimes()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CPUValidationError{
field: "Times",
reason: "embedded message failed validation",
cause: err,
}
}
}
if len(errors) > 0 {
return CPUMultiError(errors)
}
return nil
}
// CPUMultiError is an error wrapping multiple validation errors returned by
// CPU.ValidateAll() if the designated constraints aren't met.
type CPUMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m CPUMultiError) 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 CPUMultiError) AllErrors() []error { return m }
// CPUValidationError is the validation error returned by CPU.Validate if the
// designated constraints aren't met.
type CPUValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CPUValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CPUValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CPUValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CPUValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CPUValidationError) ErrorName() string { return "CPUValidationError" }
// Error satisfies the builtin error interface
func (e CPUValidationError) 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 %sCPU.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CPUValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CPUValidationError{}
// Validate checks the field values on CPUTimes 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 *CPUTimes) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on CPUTimes 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 CPUTimesMultiError, or nil
// if none found.
func (m *CPUTimes) ValidateAll() error {
return m.validate(true)
}
func (m *CPUTimes) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if m.GetUser() < 0 {
err := CPUTimesValidationError{
field: "User",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetSystem() < 0 {
err := CPUTimesValidationError{
field: "System",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetIdle() < 0 {
err := CPUTimesValidationError{
field: "Idle",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetNice() < 0 {
err := CPUTimesValidationError{
field: "Nice",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetIowait() < 0 {
err := CPUTimesValidationError{
field: "Iowait",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetIrq() < 0 {
err := CPUTimesValidationError{
field: "Irq",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetSoftirq() < 0 {
err := CPUTimesValidationError{
field: "Softirq",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetSteal() < 0 {
err := CPUTimesValidationError{
field: "Steal",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetGuest() < 0 {
err := CPUTimesValidationError{
field: "Guest",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if m.GetGuestNice() < 0 {
err := CPUTimesValidationError{
field: "GuestNice",
reason: "value must be greater than or equal to 0",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return CPUTimesMultiError(errors)
}
return nil
}
// CPUTimesMultiError is an error wrapping multiple validation errors returned
// by CPUTimes.ValidateAll() if the designated constraints aren't met.
type CPUTimesMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m CPUTimesMultiError) 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 CPUTimesMultiError) AllErrors() []error { return m }
// CPUTimesValidationError is the validation error returned by
// CPUTimes.Validate if the designated constraints aren't met.
type CPUTimesValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CPUTimesValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CPUTimesValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CPUTimesValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CPUTimesValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CPUTimesValidationError) ErrorName() string { return "CPUTimesValidationError" }
// Error satisfies the builtin error interface
func (e CPUTimesValidationError) 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 %sCPUTimes.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CPUTimesValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CPUTimesValidationError{}
// Validate checks the field values on Memory 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 *Memory) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Memory 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 MemoryMultiError, or nil if none found.
func (m *Memory) ValidateAll() error {
return m.validate(true)
}
func (m *Memory) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Total
// no validation rules for Available
// no validation rules for Used
// no validation rules for UsedPercent
// no validation rules for ProcessUsedPercent
// no validation rules for Free
if len(errors) > 0 {
return MemoryMultiError(errors)
}
return nil
}
// MemoryMultiError is an error wrapping multiple validation errors returned by
// Memory.ValidateAll() if the designated constraints aren't met.
type MemoryMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m MemoryMultiError) 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 MemoryMultiError) AllErrors() []error { return m }
// MemoryValidationError is the validation error returned by Memory.Validate if
// the designated constraints aren't met.
type MemoryValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e MemoryValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e MemoryValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e MemoryValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e MemoryValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e MemoryValidationError) ErrorName() string { return "MemoryValidationError" }
// Error satisfies the builtin error interface
func (e MemoryValidationError) 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 %sMemory.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = MemoryValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = MemoryValidationError{}
// Validate checks the field values on Network 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 *Network) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Network 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 NetworkMultiError, or nil if none found.
func (m *Network) ValidateAll() error {
return m.validate(true)
}
func (m *Network) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for TcpConnectionCount
// no validation rules for UploadTcpConnectionCount
// no validation rules for Location
// no validation rules for Idc
if len(errors) > 0 {
return NetworkMultiError(errors)
}
return nil
}
// NetworkMultiError is an error wrapping multiple validation errors returned
// by Network.ValidateAll() if the designated constraints aren't met.
type NetworkMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m NetworkMultiError) 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 NetworkMultiError) AllErrors() []error { return m }
// NetworkValidationError is the validation error returned by Network.Validate
// if the designated constraints aren't met.
type NetworkValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e NetworkValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e NetworkValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e NetworkValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e NetworkValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e NetworkValidationError) ErrorName() string { return "NetworkValidationError" }
// Error satisfies the builtin error interface
func (e NetworkValidationError) 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 %sNetwork.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = NetworkValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = NetworkValidationError{}
// Validate checks the field values on Disk 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 *Disk) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Disk 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 DiskMultiError, or nil if none found.
func (m *Disk) ValidateAll() error {
return m.validate(true)
}
func (m *Disk) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Total
// no validation rules for Free
// no validation rules for Used
if val := m.GetUsedPercent(); val < 0 || val > 100 {
err := DiskValidationError{
field: "UsedPercent",
reason: "value must be inside range [0, 100]",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for InodesTotal
// no validation rules for InodesUsed
// no validation rules for InodesFree
if val := m.GetInodesUsedPercent(); val < 0 || val > 100 {
err := DiskValidationError{
field: "InodesUsedPercent",
reason: "value must be inside range [0, 100]",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return DiskMultiError(errors)
}
return nil
}
// DiskMultiError is an error wrapping multiple validation errors returned by
// Disk.ValidateAll() if the designated constraints aren't met.
type DiskMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m DiskMultiError) 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 DiskMultiError) AllErrors() []error { return m }
// DiskValidationError is the validation error returned by Disk.Validate if the
// designated constraints aren't met.
type DiskValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e DiskValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e DiskValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e DiskValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e DiskValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e DiskValidationError) ErrorName() string { return "DiskValidationError" }
// Error satisfies the builtin error interface
func (e DiskValidationError) 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 %sDisk.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = DiskValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = DiskValidationError{}
// Validate checks the field values on Build 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 *Build) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Build 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 BuildMultiError, or nil if none found.
func (m *Build) ValidateAll() error {
return m.validate(true)
}
func (m *Build) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for GitVersion
// no validation rules for GitCommit
// no validation rules for GoVersion
// no validation rules for Platform
if len(errors) > 0 {
return BuildMultiError(errors)
}
return nil
}
// BuildMultiError is an error wrapping multiple validation errors returned by
// Build.ValidateAll() if the designated constraints aren't met.
type BuildMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m BuildMultiError) 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 BuildMultiError) AllErrors() []error { return m }
// BuildValidationError is the validation error returned by Build.Validate if
// the designated constraints aren't met.
type BuildValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e BuildValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e BuildValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e BuildValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e BuildValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e BuildValidationError) ErrorName() string { return "BuildValidationError" }
// Error satisfies the builtin error interface
func (e BuildValidationError) 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 %sBuild.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = BuildValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = BuildValidationError{}
// 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{}