mirror of https://github.com/vernonkeenan/lib
239 lines
5.7 KiB
Go
239 lines
5.7 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"
|
||
|
|
)
|
||
|
|
|
||
|
|
// EnrichmentCandidate One allowlisted human-editable field candidate supported by at least one cited source; no model confidence claim is made
|
||
|
|
//
|
||
|
|
// swagger:model EnrichmentCandidate
|
||
|
|
type EnrichmentCandidate struct {
|
||
|
|
|
||
|
|
// field name
|
||
|
|
// Required: true
|
||
|
|
// Pattern: ^(Name|AnnualRevenue|Phone|Website|Description|FullDescription|Industries|Industry|NumberOfEmployees|Location|Email|LinkedIn|Twitter|Facebook|FoundedDate|TagLine|description|enrichmentstatus|fulldescription|imagealttext|imageurl|logo|name|slug|tagline|url)$
|
||
|
|
FieldName *string `json:"FieldName"`
|
||
|
|
|
||
|
|
// ID
|
||
|
|
// Required: true
|
||
|
|
// Format: uuid
|
||
|
|
ID *strfmt.UUID `json:"ID"`
|
||
|
|
|
||
|
|
// proposed value
|
||
|
|
// Required: true
|
||
|
|
// Max Length: 20000
|
||
|
|
// Min Length: 1
|
||
|
|
ProposedValue *string `json:"ProposedValue"`
|
||
|
|
|
||
|
|
// rationale
|
||
|
|
// Max Length: 2000
|
||
|
|
Rationale string `json:"Rationale,omitempty"`
|
||
|
|
|
||
|
|
// sources
|
||
|
|
// Required: true
|
||
|
|
// Max Items: 12
|
||
|
|
// Min Items: 1
|
||
|
|
Sources []*EnrichmentSource `json:"Sources"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// Validate validates this enrichment candidate
|
||
|
|
func (m *EnrichmentCandidate) Validate(formats strfmt.Registry) error {
|
||
|
|
var res []error
|
||
|
|
|
||
|
|
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.validateProposedValue(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateRationale(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 *EnrichmentCandidate) 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, `^(Name|AnnualRevenue|Phone|Website|Description|FullDescription|Industries|Industry|NumberOfEmployees|Location|Email|LinkedIn|Twitter|Facebook|FoundedDate|TagLine|description|enrichmentstatus|fulldescription|imagealttext|imageurl|logo|name|slug|tagline|url)$`); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EnrichmentCandidate) 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 *EnrichmentCandidate) 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 *EnrichmentCandidate) validateRationale(formats strfmt.Registry) error {
|
||
|
|
if typeutils.IsZero(m.Rationale) { // not required
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.MaxLength("Rationale", "body", m.Rationale, 2000); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EnrichmentCandidate) 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 enrichment candidate based on the context it is used
|
||
|
|
func (m *EnrichmentCandidate) 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 *EnrichmentCandidate) 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 *EnrichmentCandidate) MarshalBinary() ([]byte, error) {
|
||
|
|
if m == nil {
|
||
|
|
return nil, nil
|
||
|
|
}
|
||
|
|
return jsonutils.WriteJSON(m)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UnmarshalBinary interface implementation
|
||
|
|
func (m *EnrichmentCandidate) UnmarshalBinary(b []byte) error {
|
||
|
|
var res EnrichmentCandidate
|
||
|
|
if err := jsonutils.ReadJSON(b, &res); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
*m = res
|
||
|
|
return nil
|
||
|
|
}
|