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

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

// OperatorHostRequirements operator host requirements
//
// swagger:model operator-host-requirements
type OperatorHostRequirements struct {

	// Name of the operator
	OperatorName string `json:"operator_name,omitempty"`

	// Host requirements for the operator
	Requirements *ClusterHostRequirementsDetails `json:"requirements,omitempty"`
}

// Validate validates this operator host requirements
func (m *OperatorHostRequirements) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *OperatorHostRequirements) validateRequirements(formats strfmt.Registry) error {
	if swag.IsZero(m.Requirements) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *OperatorHostRequirements) contextValidateRequirements(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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