// 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"
	"encoding/json"

	"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"
)

// CompanyProductProposalField One governed CompanyProduct field change
//
// swagger:model CompanyProductProposalField
type CompanyProductProposalField struct {

	// Current authoritative value captured when the proposal was created
	CurrentValue *string `json:"CurrentValue,omitempty"`

	// decided at
	// Format: date-time
	DecidedAt *strfmt.DateTime `json:"DecidedAt,omitempty"`

	// decided by ID
	// Format: uuid
	DecidedByID *strfmt.UUID `json:"DecidedByID,omitempty"`

	// decision
	// Enum: ["pending","accepted","rejected"]
	Decision string `json:"Decision,omitempty"`

	// decision reason
	// Max Length: 1000
	DecisionReason *string `json:"DecisionReason,omitempty"`

	// field name
	// Required: true
	// Enum: ["description","enrichmentstatus","fulldescription","imagealttext","imageurl","logo","name","slug","tagline","url"]
	FieldName *string `json:"FieldName"`

	// Proposed JSON value. The server captures the current value.
	// Required: true
	// Max Length: 20000
	ProposedValue *string `json:"ProposedValue"`
}

// Validate validates this company product proposal field
func (m *CompanyProductProposalField) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateDecidedAt(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateDecidedByID(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateDecision(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateDecisionReason(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateFieldName(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateProposedValue(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *CompanyProductProposalField) validateDecidedAt(formats strfmt.Registry) error {
	if typeutils.IsZero(m.DecidedAt) { // not required
		return nil
	}

	if err := validate.FormatOf("DecidedAt", "body", "date-time", m.DecidedAt.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CompanyProductProposalField) validateDecidedByID(formats strfmt.Registry) error {
	if typeutils.IsZero(m.DecidedByID) { // not required
		return nil
	}

	if err := validate.FormatOf("DecidedByID", "body", "uuid", m.DecidedByID.String(), formats); err != nil {
		return err
	}

	return nil
}

var companyProductProposalFieldTypeDecisionPropEnum []any

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["pending","accepted","rejected"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		companyProductProposalFieldTypeDecisionPropEnum = append(companyProductProposalFieldTypeDecisionPropEnum, v)
	}
}

const (

	// CompanyProductProposalFieldDecisionPending captures enum value "pending"
	CompanyProductProposalFieldDecisionPending string = "pending"

	// CompanyProductProposalFieldDecisionAccepted captures enum value "accepted"
	CompanyProductProposalFieldDecisionAccepted string = "accepted"

	// CompanyProductProposalFieldDecisionRejected captures enum value "rejected"
	CompanyProductProposalFieldDecisionRejected string = "rejected"
)

// prop value enum
func (m *CompanyProductProposalField) validateDecisionEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, companyProductProposalFieldTypeDecisionPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CompanyProductProposalField) validateDecision(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Decision) { // not required
		return nil
	}

	// value enum
	if err := m.validateDecisionEnum("Decision", "body", m.Decision); err != nil {
		return err
	}

	return nil
}

func (m *CompanyProductProposalField) validateDecisionReason(formats strfmt.Registry) error {
	if typeutils.IsZero(m.DecisionReason) { // not required
		return nil
	}

	if err := validate.MaxLength("DecisionReason", "body", *m.DecisionReason, 1000); err != nil {
		return err
	}

	return nil
}

var companyProductProposalFieldTypeFieldNamePropEnum []any

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["description","enrichmentstatus","fulldescription","imagealttext","imageurl","logo","name","slug","tagline","url"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		companyProductProposalFieldTypeFieldNamePropEnum = append(companyProductProposalFieldTypeFieldNamePropEnum, v)
	}
}

const (

	// CompanyProductProposalFieldFieldNameDescription captures enum value "description"
	CompanyProductProposalFieldFieldNameDescription string = "description"

	// CompanyProductProposalFieldFieldNameEnrichmentstatus captures enum value "enrichmentstatus"
	CompanyProductProposalFieldFieldNameEnrichmentstatus string = "enrichmentstatus"

	// CompanyProductProposalFieldFieldNameFulldescription captures enum value "fulldescription"
	CompanyProductProposalFieldFieldNameFulldescription string = "fulldescription"

	// CompanyProductProposalFieldFieldNameImagealttext captures enum value "imagealttext"
	CompanyProductProposalFieldFieldNameImagealttext string = "imagealttext"

	// CompanyProductProposalFieldFieldNameImageurl captures enum value "imageurl"
	CompanyProductProposalFieldFieldNameImageurl string = "imageurl"

	// CompanyProductProposalFieldFieldNameLogo captures enum value "logo"
	CompanyProductProposalFieldFieldNameLogo string = "logo"

	// CompanyProductProposalFieldFieldNameName captures enum value "name"
	CompanyProductProposalFieldFieldNameName string = "name"

	// CompanyProductProposalFieldFieldNameSlug captures enum value "slug"
	CompanyProductProposalFieldFieldNameSlug string = "slug"

	// CompanyProductProposalFieldFieldNameTagline captures enum value "tagline"
	CompanyProductProposalFieldFieldNameTagline string = "tagline"

	// CompanyProductProposalFieldFieldNameURL captures enum value "url"
	CompanyProductProposalFieldFieldNameURL string = "url"
)

// prop value enum
func (m *CompanyProductProposalField) validateFieldNameEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, companyProductProposalFieldTypeFieldNamePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CompanyProductProposalField) validateFieldName(formats strfmt.Registry) error {

	if err := validate.Required("FieldName", "body", m.FieldName); err != nil {
		return err
	}

	// value enum
	if err := m.validateFieldNameEnum("FieldName", "body", *m.FieldName); err != nil {
		return err
	}

	return nil
}

func (m *CompanyProductProposalField) validateProposedValue(formats strfmt.Registry) error {

	if err := validate.Required("ProposedValue", "body", m.ProposedValue); err != nil {
		return err
	}

	if err := validate.MaxLength("ProposedValue", "body", *m.ProposedValue, 20000); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this company product proposal field based on context it is used
func (m *CompanyProductProposalField) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (m *CompanyProductProposalField) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return jsonutils.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *CompanyProductProposalField) UnmarshalBinary(b []byte) error {
	var res CompanyProductProposalField
	if err := jsonutils.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
