// Code generated by protoc-gen-validate. DO NOT EDIT. // source: pkg/rpc/base/base.proto package base import ( "bytes" "errors" "fmt" "net" "net/mail" "net/url" "regexp" "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{} ) // Validate checks the field values on GrpcDfError with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned. func (m *GrpcDfError) Validate() error { if m == nil { return nil } // no validation rules for Code // no validation rules for Message return nil } // GrpcDfErrorValidationError is the validation error returned by // GrpcDfError.Validate if the designated constraints aren't met. type GrpcDfErrorValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e GrpcDfErrorValidationError) Field() string { return e.field } // Reason function returns reason value. func (e GrpcDfErrorValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e GrpcDfErrorValidationError) Cause() error { return e.cause } // Key function returns key value. func (e GrpcDfErrorValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e GrpcDfErrorValidationError) ErrorName() string { return "GrpcDfErrorValidationError" } // Error satisfies the builtin error interface func (e GrpcDfErrorValidationError) 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 %sGrpcDfError.%s: %s%s", key, e.field, e.reason, cause) } var _ error = GrpcDfErrorValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = GrpcDfErrorValidationError{} // Validate checks the field values on UrlMeta with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned. func (m *UrlMeta) Validate() error { if m == nil { return nil } if m.GetDigest() != "" { if !_UrlMeta_Digest_Pattern.MatchString(m.GetDigest()) { return UrlMetaValidationError{ field: "Digest", reason: "value does not match regex pattern \"^(md5)|(sha256):[A-Fa-f0-9]+$\"", } } } // no validation rules for Tag if m.GetRange() != "" { if !_UrlMeta_Range_Pattern.MatchString(m.GetRange()) { return UrlMetaValidationError{ field: "Range", reason: "value does not match regex pattern \"^[0-9]+-[0-9]*$\"", } } } // no validation rules for Filter // no validation rules for Header return nil } // UrlMetaValidationError is the validation error returned by UrlMeta.Validate // if the designated constraints aren't met. type UrlMetaValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e UrlMetaValidationError) Field() string { return e.field } // Reason function returns reason value. func (e UrlMetaValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e UrlMetaValidationError) Cause() error { return e.cause } // Key function returns key value. func (e UrlMetaValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e UrlMetaValidationError) ErrorName() string { return "UrlMetaValidationError" } // Error satisfies the builtin error interface func (e UrlMetaValidationError) 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 %sUrlMeta.%s: %s%s", key, e.field, e.reason, cause) } var _ error = UrlMetaValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = UrlMetaValidationError{} var _UrlMeta_Digest_Pattern = regexp.MustCompile("^(md5)|(sha256):[A-Fa-f0-9]+$") var _UrlMeta_Range_Pattern = regexp.MustCompile("^[0-9]+-[0-9]*$") // Validate checks the field values on HostLoad with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned. func (m *HostLoad) Validate() error { if m == nil { return nil } if val := m.GetCpuRatio(); val < 0 || val > 1 { return HostLoadValidationError{ field: "CpuRatio", reason: "value must be inside range [0, 1]", } } if val := m.GetMemRatio(); val < 0 || val > 1 { return HostLoadValidationError{ field: "MemRatio", reason: "value must be inside range [0, 1]", } } if val := m.GetDiskRatio(); val < 0 || val > 1 { return HostLoadValidationError{ field: "DiskRatio", reason: "value must be inside range [0, 1]", } } return nil } // HostLoadValidationError is the validation error returned by // HostLoad.Validate if the designated constraints aren't met. type HostLoadValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e HostLoadValidationError) Field() string { return e.field } // Reason function returns reason value. func (e HostLoadValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e HostLoadValidationError) Cause() error { return e.cause } // Key function returns key value. func (e HostLoadValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e HostLoadValidationError) ErrorName() string { return "HostLoadValidationError" } // Error satisfies the builtin error interface func (e HostLoadValidationError) 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 %sHostLoad.%s: %s%s", key, e.field, e.reason, cause) } var _ error = HostLoadValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = HostLoadValidationError{} // Validate checks the field values on PieceTaskRequest with the rules defined // in the proto definition for this message. If any rules are violated, an // error is returned. func (m *PieceTaskRequest) Validate() error { if m == nil { return nil } if utf8.RuneCountInString(m.GetTaskId()) < 1 { return PieceTaskRequestValidationError{ field: "TaskId", reason: "value length must be at least 1 runes", } } if utf8.RuneCountInString(m.GetSrcPid()) < 1 { return PieceTaskRequestValidationError{ field: "SrcPid", reason: "value length must be at least 1 runes", } } if utf8.RuneCountInString(m.GetDstPid()) < 1 { return PieceTaskRequestValidationError{ field: "DstPid", reason: "value length must be at least 1 runes", } } if m.GetStartNum() < 0 { return PieceTaskRequestValidationError{ field: "StartNum", reason: "value must be greater than or equal to 0", } } if m.GetLimit() < 0 { return PieceTaskRequestValidationError{ field: "Limit", reason: "value must be greater than or equal to 0", } } return nil } // PieceTaskRequestValidationError is the validation error returned by // PieceTaskRequest.Validate if the designated constraints aren't met. type PieceTaskRequestValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PieceTaskRequestValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PieceTaskRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PieceTaskRequestValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PieceTaskRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PieceTaskRequestValidationError) ErrorName() string { return "PieceTaskRequestValidationError" } // Error satisfies the builtin error interface func (e PieceTaskRequestValidationError) 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 %sPieceTaskRequest.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PieceTaskRequestValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PieceTaskRequestValidationError{} // Validate checks the field values on PieceInfo with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned. func (m *PieceInfo) Validate() error { if m == nil { return nil } // no validation rules for PieceNum if m.GetRangeStart() < 0 { return PieceInfoValidationError{ field: "RangeStart", reason: "value must be greater than or equal to 0", } } if m.GetRangeSize() < 0 { return PieceInfoValidationError{ field: "RangeSize", reason: "value must be greater than or equal to 0", } } if m.GetPieceMd5() != "" { if !_PieceInfo_PieceMd5_Pattern.MatchString(m.GetPieceMd5()) { return PieceInfoValidationError{ field: "PieceMd5", reason: "value does not match regex pattern \"([a-f\\\\d]{32}|[A-F\\\\d]{32}|[a-f\\\\d]{16}|[A-F\\\\d]{16})\"", } } } if m.GetPieceOffset() < 0 { return PieceInfoValidationError{ field: "PieceOffset", reason: "value must be greater than or equal to 0", } } // no validation rules for PieceStyle if m.GetDownloadCost() < 0 { return PieceInfoValidationError{ field: "DownloadCost", reason: "value must be greater than or equal to 0", } } return nil } // PieceInfoValidationError is the validation error returned by // PieceInfo.Validate if the designated constraints aren't met. type PieceInfoValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PieceInfoValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PieceInfoValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PieceInfoValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PieceInfoValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PieceInfoValidationError) ErrorName() string { return "PieceInfoValidationError" } // Error satisfies the builtin error interface func (e PieceInfoValidationError) 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 %sPieceInfo.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PieceInfoValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PieceInfoValidationError{} var _PieceInfo_PieceMd5_Pattern = regexp.MustCompile("([a-f\\d]{32}|[A-F\\d]{32}|[a-f\\d]{16}|[A-F\\d]{16})") // Validate checks the field values on ExtendAttribute with the rules defined // in the proto definition for this message. If any rules are violated, an // error is returned. func (m *ExtendAttribute) Validate() error { if m == nil { return nil } // no validation rules for Header return nil } // ExtendAttributeValidationError is the validation error returned by // ExtendAttribute.Validate if the designated constraints aren't met. type ExtendAttributeValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e ExtendAttributeValidationError) Field() string { return e.field } // Reason function returns reason value. func (e ExtendAttributeValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e ExtendAttributeValidationError) Cause() error { return e.cause } // Key function returns key value. func (e ExtendAttributeValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e ExtendAttributeValidationError) ErrorName() string { return "ExtendAttributeValidationError" } // Error satisfies the builtin error interface func (e ExtendAttributeValidationError) 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 %sExtendAttribute.%s: %s%s", key, e.field, e.reason, cause) } var _ error = ExtendAttributeValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = ExtendAttributeValidationError{} // Validate checks the field values on PiecePacket with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned. func (m *PiecePacket) Validate() error { if m == nil { return nil } if utf8.RuneCountInString(m.GetTaskId()) < 1 { return PiecePacketValidationError{ field: "TaskId", reason: "value length must be at least 1 runes", } } if utf8.RuneCountInString(m.GetDstPid()) < 1 { return PiecePacketValidationError{ field: "DstPid", reason: "value length must be at least 1 runes", } } if utf8.RuneCountInString(m.GetDstAddr()) < 1 { return PiecePacketValidationError{ field: "DstAddr", reason: "value length must be at least 1 runes", } } for idx, item := range m.GetPieceInfos() { _, _ = idx, item if v, ok := any(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PiecePacketValidationError{ field: fmt.Sprintf("PieceInfos[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } // no validation rules for TotalPiece // no validation rules for ContentLength // no validation rules for PieceMd5Sign if v, ok := any(m.GetExtendAttribute()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PiecePacketValidationError{ field: "ExtendAttribute", reason: "embedded message failed validation", cause: err, } } } return nil } // PiecePacketValidationError is the validation error returned by // PiecePacket.Validate if the designated constraints aren't met. type PiecePacketValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PiecePacketValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PiecePacketValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PiecePacketValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PiecePacketValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PiecePacketValidationError) ErrorName() string { return "PiecePacketValidationError" } // Error satisfies the builtin error interface func (e PiecePacketValidationError) 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 %sPiecePacket.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PiecePacketValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PiecePacketValidationError{}