// Code generated by protoc-gen-validate. DO NOT EDIT. // source: pkg/apis/common/v2/common.proto package v2 import ( "bytes" "errors" "fmt" "net" "net/mail" "net/url" "regexp" "sort" "strings" "time" "unicode/utf8" "google.golang.org/protobuf/types/known/anypb" ) // ensure the imports are used var ( _ = bytes.MinRead _ = errors.New("") _ = fmt.Print _ = utf8.UTFMax _ = (*regexp.Regexp)(nil) _ = (*strings.Reader)(nil) _ = net.IPv4len _ = time.Duration(0) _ = (*url.URL)(nil) _ = (*mail.Address)(nil) _ = anypb.Any{} _ = sort.Sort ) // Validate checks the field values on Range 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 *Range) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Range 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 RangeMultiError, or nil if none found. func (m *Range) ValidateAll() error { return m.validate(true) } func (m *Range) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Begin // no validation rules for End if len(errors) > 0 { return RangeMultiError(errors) } return nil } // RangeMultiError is an error wrapping multiple validation errors returned by // Range.ValidateAll() if the designated constraints aren't met. type RangeMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RangeMultiError) 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 RangeMultiError) AllErrors() []error { return m } // RangeValidationError is the validation error returned by Range.Validate if // the designated constraints aren't met. type RangeValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e RangeValidationError) Field() string { return e.field } // Reason function returns reason value. func (e RangeValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e RangeValidationError) Cause() error { return e.cause } // Key function returns key value. func (e RangeValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e RangeValidationError) ErrorName() string { return "RangeValidationError" } // Error satisfies the builtin error interface func (e RangeValidationError) 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 %sRange.%s: %s%s", key, e.field, e.reason, cause) } var _ error = RangeValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = RangeValidationError{} // Validate checks the field values on Metadata 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 *Metadata) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Metadata 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 MetadataMultiError, or nil // if none found. func (m *Metadata) ValidateAll() error { return m.validate(true) } func (m *Metadata) validate(all bool) error { if m == nil { return nil } var errors []error if uri, err := url.Parse(m.GetUrl()); err != nil { err = MetadataValidationError{ field: "Url", reason: "value must be a valid URI", cause: err, } if !all { return err } errors = append(errors, err) } else if !uri.IsAbs() { err := MetadataValidationError{ field: "Url", reason: "value must be absolute", } if !all { return err } errors = append(errors, err) } if m.GetDigest() != "" { if !_Metadata_Digest_Pattern.MatchString(m.GetDigest()) { err := MetadataValidationError{ field: "Digest", reason: "value does not match regex pattern \"^(md5)|(sha256):[A-Fa-f0-9]+$\"", } if !all { return err } errors = append(errors, err) } } if all { switch v := interface{}(m.GetRange()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, MetadataValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, MetadataValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetRange()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return MetadataValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, } } } // no validation rules for Tag // no validation rules for Application // no validation rules for Header if m.GetPieceSize() < 1 { err := MetadataValidationError{ field: "PieceSize", reason: "value must be greater than or equal to 1", } if !all { return err } errors = append(errors, err) } if len(errors) > 0 { return MetadataMultiError(errors) } return nil } // MetadataMultiError is an error wrapping multiple validation errors returned // by Metadata.ValidateAll() if the designated constraints aren't met. type MetadataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m MetadataMultiError) 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 MetadataMultiError) AllErrors() []error { return m } // MetadataValidationError is the validation error returned by // Metadata.Validate if the designated constraints aren't met. type MetadataValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e MetadataValidationError) Field() string { return e.field } // Reason function returns reason value. func (e MetadataValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e MetadataValidationError) Cause() error { return e.cause } // Key function returns key value. func (e MetadataValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e MetadataValidationError) ErrorName() string { return "MetadataValidationError" } // Error satisfies the builtin error interface func (e MetadataValidationError) 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 %sMetadata.%s: %s%s", key, e.field, e.reason, cause) } var _ error = MetadataValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = MetadataValidationError{} var _Metadata_Digest_Pattern = regexp.MustCompile("^(md5)|(sha256):[A-Fa-f0-9]+$") // Validate checks the field values on Piece 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 *Piece) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Piece 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 PieceMultiError, or nil if none found. func (m *Piece) ValidateAll() error { return m.validate(true) } func (m *Piece) validate(all bool) error { if m == nil { return nil } var errors []error if m.GetNumber() < 0 { err := PieceValidationError{ field: "Number", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if utf8.RuneCountInString(m.GetParentId()) < 1 { err := PieceValidationError{ field: "ParentId", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if m.GetOffset() < 0 { err := PieceValidationError{ field: "Offset", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetSize() <= 0 { err := PieceValidationError{ field: "Size", reason: "value must be greater than 0", } if !all { return err } errors = append(errors, err) } if m.GetDigest() != "" { if !_Piece_Digest_Pattern.MatchString(m.GetDigest()) { err := PieceValidationError{ field: "Digest", reason: "value does not match regex pattern \"^(md5)|(sha256):[A-Fa-f0-9]+$\"", } if !all { return err } errors = append(errors, err) } } // no validation rules for TrafficType if m.GetCost() == nil { err := PieceValidationError{ field: "Cost", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.GetCreatedAt() == nil { err := PieceValidationError{ field: "CreatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if len(errors) > 0 { return PieceMultiError(errors) } return nil } // PieceMultiError is an error wrapping multiple validation errors returned by // Piece.ValidateAll() if the designated constraints aren't met. type PieceMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PieceMultiError) 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 PieceMultiError) AllErrors() []error { return m } // PieceValidationError is the validation error returned by Piece.Validate if // the designated constraints aren't met. type PieceValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PieceValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PieceValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PieceValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PieceValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PieceValidationError) ErrorName() string { return "PieceValidationError" } // Error satisfies the builtin error interface func (e PieceValidationError) 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 %sPiece.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PieceValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PieceValidationError{} var _Piece_Digest_Pattern = regexp.MustCompile("^(md5)|(sha256):[A-Fa-f0-9]+$") // Validate checks the field values on ExtendAttribute 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 *ExtendAttribute) Validate() error { return m.validate(false) } // ValidateAll checks the field values on ExtendAttribute 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 // ExtendAttributeMultiError, or nil if none found. func (m *ExtendAttribute) ValidateAll() error { return m.validate(true) } func (m *ExtendAttribute) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Header if val := m.GetStatusCode(); val < 100 || val >= 599 { err := ExtendAttributeValidationError{ field: "StatusCode", reason: "value must be inside range [100, 599)", } if !all { return err } errors = append(errors, err) } if utf8.RuneCountInString(m.GetStatus()) < 1 { err := ExtendAttributeValidationError{ field: "Status", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if len(errors) > 0 { return ExtendAttributeMultiError(errors) } return nil } // ExtendAttributeMultiError is an error wrapping multiple validation errors // returned by ExtendAttribute.ValidateAll() if the designated constraints // aren't met. type ExtendAttributeMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ExtendAttributeMultiError) 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 ExtendAttributeMultiError) AllErrors() []error { return m } // 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{}