// 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"
	"github.com/go-openapi/validate"
)

// HashicorpCloudGlobalNetworkManager20220215ConsulMajorVersion hashicorp cloud global network manager 20220215 consul major version
//
// swagger:model hashicorp.cloud.global_network_manager_20220215.ConsulMajorVersion
type HashicorpCloudGlobalNetworkManager20220215ConsulMajorVersion struct {

	// documentation
	Documentation []string `json:"documentation"`

	// end of life
	EndOfLife bool `json:"end_of_life,omitempty"`

	// minor versions
	MinorVersions map[string]HashicorpCloudGlobalNetworkManager20220215ConsulMinorVersion `json:"minor_versions,omitempty"`
}

// Validate validates this hashicorp cloud global network manager 20220215 consul major version
func (m *HashicorpCloudGlobalNetworkManager20220215ConsulMajorVersion) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215ConsulMajorVersion) validateMinorVersions(formats strfmt.Registry) error {
	if swag.IsZero(m.MinorVersions) { // not required
		return nil
	}

	for k := range m.MinorVersions {

		if err := validate.Required("minor_versions"+"."+k, "body", m.MinorVersions[k]); err != nil {
			return err
		}
		if val, ok := m.MinorVersions[k]; ok {
			if err := val.Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("minor_versions" + "." + k)
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("minor_versions" + "." + k)
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this hashicorp cloud global network manager 20220215 consul major version based on the context it is used
func (m *HashicorpCloudGlobalNetworkManager20220215ConsulMajorVersion) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215ConsulMajorVersion) contextValidateMinorVersions(ctx context.Context, formats strfmt.Registry) error {

	for k := range m.MinorVersions {

		if val, ok := m.MinorVersions[k]; ok {
			if err := val.ContextValidate(ctx, formats); err != nil {
				return err
			}
		}

	}

	return nil
}

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

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