// Code generated by go-swagger; DO NOT EDIT.

// (c) 2012-2023 by Vernon Keenan
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package sfgate_models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// IndustryService Junction Object between Industry and CompanyService
//
// swagger:model IndustryService
type IndustryService struct {

	// company service
	CompanyService *CompanyService `json:"CompanyService,omitempty"`

	// company service ID
	CompanyServiceID *string `json:"CompanyServiceID,omitempty"`

	// Created By User ID
	CreatedByID *string `json:"CreatedByID,omitempty"`

	// Created Date
	CreatedDate *string `json:"CreatedDate,omitempty"`

	// Record Id
	ID string `json:"ID,omitempty"`

	// industry
	Industry *Industry `json:"Industry,omitempty"`

	// industry ID
	IndustryID *string `json:"IndustryID,omitempty"`

	// Last Modified By User ID
	LastModifiedByID *string `json:"LastModifiedByID,omitempty"`

	// Last Modified Date
	LastModifiedDate *string `json:"LastModifiedDate,omitempty"`
}

// Validate validates this industry service
func (m *IndustryService) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *IndustryService) validateCompanyService(formats strfmt.Registry) error {
	if swag.IsZero(m.CompanyService) { // not required
		return nil
	}

	if m.CompanyService != nil {
		if err := m.CompanyService.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("CompanyService")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("CompanyService")
			}
			return err
		}
	}

	return nil
}

func (m *IndustryService) validateIndustry(formats strfmt.Registry) error {
	if swag.IsZero(m.Industry) { // not required
		return nil
	}

	if m.Industry != nil {
		if err := m.Industry.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("Industry")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("Industry")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this industry service based on the context it is used
func (m *IndustryService) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *IndustryService) contextValidateCompanyService(ctx context.Context, formats strfmt.Registry) error {

	if m.CompanyService != nil {
		if err := m.CompanyService.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("CompanyService")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("CompanyService")
			}
			return err
		}
	}

	return nil
}

func (m *IndustryService) contextValidateIndustry(ctx context.Context, formats strfmt.Registry) error {

	if m.Industry != nil {
		if err := m.Industry.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("Industry")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("Industry")
			}
			return err
		}
	}

	return nil
}

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

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