// Code generated by go-swagger; DO NOT EDIT. // (c) 2012-2020 by Taxnexus, Inc. // All rights reserved worldwide. // Proprietary product; unlicensed use is not allowed package research_models import ( "context" stderrors "errors" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) // PortfolioEnrichmentClassification One cited classification label discovered for a Product or Service // // swagger:model PortfolioEnrichmentClassification type PortfolioEnrichmentClassification struct { // label // Required: true // Max Length: 255 // Min Length: 1 Label *string `json:"Label"` // normalized label // Required: true // Max Length: 255 // Min Length: 1 NormalizedLabel *string `json:"NormalizedLabel"` // observed date // Required: true // Format: date-time ObservedDate *strfmt.DateTime `json:"ObservedDate"` // sources // Required: true // Max Items: 12 // Min Items: 1 Sources []*PortfolioEnrichmentSource `json:"Sources"` } // Validate validates this portfolio enrichment classification func (m *PortfolioEnrichmentClassification) Validate(formats strfmt.Registry) error { var res []error if err := m.validateLabel(formats); err != nil { res = append(res, err) } if err := m.validateNormalizedLabel(formats); err != nil { res = append(res, err) } if err := m.validateObservedDate(formats); err != nil { res = append(res, err) } if err := m.validateSources(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *PortfolioEnrichmentClassification) validateLabel(formats strfmt.Registry) error { if err := validate.Required("Label", "body", m.Label); err != nil { return err } if err := validate.MinLength("Label", "body", *m.Label, 1); err != nil { return err } if err := validate.MaxLength("Label", "body", *m.Label, 255); err != nil { return err } return nil } func (m *PortfolioEnrichmentClassification) validateNormalizedLabel(formats strfmt.Registry) error { if err := validate.Required("NormalizedLabel", "body", m.NormalizedLabel); err != nil { return err } if err := validate.MinLength("NormalizedLabel", "body", *m.NormalizedLabel, 1); err != nil { return err } if err := validate.MaxLength("NormalizedLabel", "body", *m.NormalizedLabel, 255); err != nil { return err } return nil } func (m *PortfolioEnrichmentClassification) validateObservedDate(formats strfmt.Registry) error { if err := validate.Required("ObservedDate", "body", m.ObservedDate); err != nil { return err } if err := validate.FormatOf("ObservedDate", "body", "date-time", m.ObservedDate.String(), formats); err != nil { return err } return nil } func (m *PortfolioEnrichmentClassification) validateSources(formats strfmt.Registry) error { if err := validate.Required("Sources", "body", m.Sources); err != nil { return err } iSourcesSize := int64(len(m.Sources)) if err := validate.MinItems("Sources", "body", iSourcesSize, 1); err != nil { return err } if err := validate.MaxItems("Sources", "body", iSourcesSize, 12); err != nil { return err } for i := 0; i < len(m.Sources); i++ { if typeutils.IsZero(m.Sources[i]) { // not required continue } if m.Sources[i] != nil { if err := m.Sources[i].Validate(formats); err != nil { ve := new(errors.Validation) if stderrors.As(err, &ve) { return ve.ValidateName("Sources" + "." + strconv.Itoa(i)) } ce := new(errors.CompositeError) if stderrors.As(err, &ce) { return ce.ValidateName("Sources" + "." + strconv.Itoa(i)) } return err } } } return nil } // ContextValidate validate this portfolio enrichment classification based on the context it is used func (m *PortfolioEnrichmentClassification) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateSources(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *PortfolioEnrichmentClassification) contextValidateSources(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Sources); i++ { if m.Sources[i] != nil { if typeutils.IsZero(m.Sources[i]) { // not required return nil } if err := m.Sources[i].ContextValidate(ctx, formats); err != nil { ve := new(errors.Validation) if stderrors.As(err, &ve) { return ve.ValidateName("Sources" + "." + strconv.Itoa(i)) } ce := new(errors.CompositeError) if stderrors.As(err, &ce) { return ce.ValidateName("Sources" + "." + strconv.Itoa(i)) } return err } } } return nil } // MarshalBinary interface implementation func (m *PortfolioEnrichmentClassification) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *PortfolioEnrichmentClassification) UnmarshalBinary(b []byte) error { var res PortfolioEnrichmentClassification if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res return nil }