lib/api/research/research_models/portfolio_enrichment_summar...

197 lines
4.4 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"
)
// PortfolioEnrichmentSummary One cited human-readable executive summary for a completed portfolio_enrichment.v1 run
//
// swagger:model PortfolioEnrichmentSummary
type PortfolioEnrichmentSummary struct {
// 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"`
// text
// Required: true
// Max Length: 20000
// Min Length: 1
Text *string `json:"Text"`
}
// Validate validates this portfolio enrichment summary
func (m *PortfolioEnrichmentSummary) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateObservedDate(formats); err != nil {
res = append(res, err)
}
if err := m.validateSources(formats); err != nil {
res = append(res, err)
}
if err := m.validateText(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *PortfolioEnrichmentSummary) 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 *PortfolioEnrichmentSummary) 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
}
func (m *PortfolioEnrichmentSummary) validateText(formats strfmt.Registry) error {
if err := validate.Required("Text", "body", m.Text); err != nil {
return err
}
if err := validate.MinLength("Text", "body", *m.Text, 1); err != nil {
return err
}
if err := validate.MaxLength("Text", "body", *m.Text, 20000); err != nil {
return err
}
return nil
}
// ContextValidate validate this portfolio enrichment summary based on the context it is used
func (m *PortfolioEnrichmentSummary) 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 *PortfolioEnrichmentSummary) 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 *PortfolioEnrichmentSummary) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return jsonutils.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PortfolioEnrichmentSummary) UnmarshalBinary(b []byte) error {
var res PortfolioEnrichmentSummary
if err := jsonutils.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}