lib/api/research/research_models/portfolio_enrichment_input.go

215 lines
4.9 KiB
Go
Raw Normal View History

// 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"
)
// PortfolioEnrichmentInput Bounded, non-secret Account context used for one portfolio_enrichment.v1 run
//
// swagger:model PortfolioEnrichmentInput
type PortfolioEnrichmentInput struct {
// account name
// Required: true
// Max Length: 255
// Min Length: 1
AccountName *string `json:"AccountName"`
// account website
// Max Length: 2048
// Format: uri
AccountWebsite strfmt.URI `json:"AccountWebsite,omitempty"`
// fact sheet digest
// Pattern: ^sha256:[a-f0-9]{64}$
FactSheetDigest string `json:"FactSheetDigest,omitempty"`
// facts
// Required: true
// Max Items: 100
Facts []*PortfolioEnrichmentInputFact `json:"Facts"`
}
// Validate validates this portfolio enrichment input
func (m *PortfolioEnrichmentInput) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAccountName(formats); err != nil {
res = append(res, err)
}
if err := m.validateAccountWebsite(formats); err != nil {
res = append(res, err)
}
if err := m.validateFactSheetDigest(formats); err != nil {
res = append(res, err)
}
if err := m.validateFacts(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *PortfolioEnrichmentInput) validateAccountName(formats strfmt.Registry) error {
if err := validate.Required("AccountName", "body", m.AccountName); err != nil {
return err
}
if err := validate.MinLength("AccountName", "body", *m.AccountName, 1); err != nil {
return err
}
if err := validate.MaxLength("AccountName", "body", *m.AccountName, 255); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentInput) validateAccountWebsite(formats strfmt.Registry) error {
if typeutils.IsZero(m.AccountWebsite) { // not required
return nil
}
if err := validate.MaxLength("AccountWebsite", "body", m.AccountWebsite.String(), 2048); err != nil {
return err
}
if err := validate.FormatOf("AccountWebsite", "body", "uri", m.AccountWebsite.String(), formats); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentInput) validateFactSheetDigest(formats strfmt.Registry) error {
if typeutils.IsZero(m.FactSheetDigest) { // not required
return nil
}
if err := validate.Pattern("FactSheetDigest", "body", m.FactSheetDigest, `^sha256:[a-f0-9]{64}$`); err != nil {
return err
}
return nil
}
func (m *PortfolioEnrichmentInput) validateFacts(formats strfmt.Registry) error {
if err := validate.Required("Facts", "body", m.Facts); err != nil {
return err
}
iFactsSize := int64(len(m.Facts))
if err := validate.MaxItems("Facts", "body", iFactsSize, 100); err != nil {
return err
}
for i := 0; i < len(m.Facts); i++ {
if typeutils.IsZero(m.Facts[i]) { // not required
continue
}
if m.Facts[i] != nil {
if err := m.Facts[i].Validate(formats); err != nil {
ve := new(errors.Validation)
if stderrors.As(err, &ve) {
return ve.ValidateName("Facts" + "." + strconv.Itoa(i))
}
ce := new(errors.CompositeError)
if stderrors.As(err, &ce) {
return ce.ValidateName("Facts" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this portfolio enrichment input based on the context it is used
func (m *PortfolioEnrichmentInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateFacts(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *PortfolioEnrichmentInput) contextValidateFacts(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Facts); i++ {
if m.Facts[i] != nil {
if typeutils.IsZero(m.Facts[i]) { // not required
return nil
}
if err := m.Facts[i].ContextValidate(ctx, formats); err != nil {
ve := new(errors.Validation)
if stderrors.As(err, &ve) {
return ve.ValidateName("Facts" + "." + strconv.Itoa(i))
}
ce := new(errors.CompositeError)
if stderrors.As(err, &ce) {
return ce.ValidateName("Facts" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *PortfolioEnrichmentInput) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return jsonutils.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PortfolioEnrichmentInput) UnmarshalBinary(b []byte) error {
var res PortfolioEnrichmentInput
if err := jsonutils.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}