lib/api/research/research_models/portfolio_enrichment_field.go

305 lines
7.1 KiB
Go

// 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"
)
// PortfolioEnrichmentField One Research-assembled Product or Service field comparison in portfolio_enrichment.v1
//
// swagger:model PortfolioEnrichmentField
type PortfolioEnrichmentField struct {
// existing value
// Max Length: 20000
ExistingValue string `json:"ExistingValue,omitempty"`
// existing value captured
// Required: true
ExistingValueCaptured *bool `json:"ExistingValueCaptured"`
// field name
// Required: true
// Pattern: ^(description|fulldescription|imagealttext|imageurl|logo|name|slug|tagline|url)$
FieldName *string `json:"FieldName"`
// ID
// Required: true
// Format: uuid
ID *strfmt.UUID `json:"ID"`
// normalized value
// Required: true
// Max Length: 20000
// Min Length: 1
NormalizedValue *string `json:"NormalizedValue"`
// observed date
// Required: true
// Format: date-time
ObservedDate *strfmt.DateTime `json:"ObservedDate"`
// proposed value
// Required: true
// Max Length: 20000
// Min Length: 1
ProposedValue *string `json:"ProposedValue"`
// sources
// Required: true
// Max Items: 12
// Min Items: 1
Sources []*PortfolioEnrichmentSource `json:"Sources"`
}
// Validate validates this portfolio enrichment field
func (m *PortfolioEnrichmentField) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateExistingValue(formats); err != nil {
res = append(res, err)
}
if err := m.validateExistingValueCaptured(formats); err != nil {
res = append(res, err)
}
if err := m.validateFieldName(formats); err != nil {
res = append(res, err)
}
if err := m.validateID(formats); err != nil {
res = append(res, err)
}
if err := m.validateNormalizedValue(formats); err != nil {
res = append(res, err)
}
if err := m.validateObservedDate(formats); err != nil {
res = append(res, err)
}
if err := m.validateProposedValue(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 *PortfolioEnrichmentField) validateExistingValue(formats strfmt.Registry) error {
if typeutils.IsZero(m.ExistingValue) { // not required
return nil
}
if err := validate.MaxLength("ExistingValue", "body", m.ExistingValue, 20000); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentField) validateExistingValueCaptured(formats strfmt.Registry) error {
if err := validate.Required("ExistingValueCaptured", "body", m.ExistingValueCaptured); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentField) validateFieldName(formats strfmt.Registry) error {
if err := validate.Required("FieldName", "body", m.FieldName); err != nil {
return err
}
if err := validate.Pattern("FieldName", "body", *m.FieldName, `^(description|fulldescription|imagealttext|imageurl|logo|name|slug|tagline|url)$`); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentField) validateID(formats strfmt.Registry) error {
if err := validate.Required("ID", "body", m.ID); err != nil {
return err
}
if err := validate.FormatOf("ID", "body", "uuid", m.ID.String(), formats); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentField) validateNormalizedValue(formats strfmt.Registry) error {
if err := validate.Required("NormalizedValue", "body", m.NormalizedValue); err != nil {
return err
}
if err := validate.MinLength("NormalizedValue", "body", *m.NormalizedValue, 1); err != nil {
return err
}
if err := validate.MaxLength("NormalizedValue", "body", *m.NormalizedValue, 20000); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentField) 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 *PortfolioEnrichmentField) validateProposedValue(formats strfmt.Registry) error {
if err := validate.Required("ProposedValue", "body", m.ProposedValue); err != nil {
return err
}
if err := validate.MinLength("ProposedValue", "body", *m.ProposedValue, 1); err != nil {
return err
}
if err := validate.MaxLength("ProposedValue", "body", *m.ProposedValue, 20000); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentField) 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 field based on the context it is used
func (m *PortfolioEnrichmentField) 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 *PortfolioEnrichmentField) 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 *PortfolioEnrichmentField) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return jsonutils.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PortfolioEnrichmentField) UnmarshalBinary(b []byte) error {
var res PortfolioEnrichmentField
if err := jsonutils.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}