mirror of https://github.com/vernonkeenan/lib
246 lines
5.9 KiB
Go
246 lines
5.9 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"
|
||
|
|
)
|
||
|
|
|
||
|
|
// PortfolioEnrichmentObservedField One normalized, cited Product or Service field observation emitted by the non-authoritative worker
|
||
|
|
//
|
||
|
|
// swagger:model PortfolioEnrichmentObservedField
|
||
|
|
type PortfolioEnrichmentObservedField struct {
|
||
|
|
|
||
|
|
// field name
|
||
|
|
// Required: true
|
||
|
|
// Pattern: ^(description|fulldescription|imagealttext|imageurl|logo|name|slug|tagline|url)$
|
||
|
|
FieldName *string `json:"FieldName"`
|
||
|
|
|
||
|
|
// 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 observed field
|
||
|
|
func (m *PortfolioEnrichmentObservedField) Validate(formats strfmt.Registry) error {
|
||
|
|
var res []error
|
||
|
|
|
||
|
|
if err := m.validateFieldName(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 *PortfolioEnrichmentObservedField) 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 *PortfolioEnrichmentObservedField) 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 *PortfolioEnrichmentObservedField) 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 *PortfolioEnrichmentObservedField) 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 *PortfolioEnrichmentObservedField) 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 observed field based on the context it is used
|
||
|
|
func (m *PortfolioEnrichmentObservedField) 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 *PortfolioEnrichmentObservedField) 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 *PortfolioEnrichmentObservedField) MarshalBinary() ([]byte, error) {
|
||
|
|
if m == nil {
|
||
|
|
return nil, nil
|
||
|
|
}
|
||
|
|
return jsonutils.WriteJSON(m)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UnmarshalBinary interface implementation
|
||
|
|
func (m *PortfolioEnrichmentObservedField) UnmarshalBinary(b []byte) error {
|
||
|
|
var res PortfolioEnrichmentObservedField
|
||
|
|
if err := jsonutils.ReadJSON(b, &res); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
*m = res
|
||
|
|
return nil
|
||
|
|
}
|