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

// HashicorpCloudGlobalNetworkManager20220215ListConsulVersionsResponse hashicorp cloud global network manager 20220215 list consul versions response
//
// swagger:model hashicorp.cloud.global_network_manager_20220215.ListConsulVersionsResponse
type HashicorpCloudGlobalNetworkManager20220215ListConsulVersionsResponse struct {

	// cves
	Cves map[string]HashicorpCloudGlobalNetworkManager20220215CVE `json:"cves,omitempty"`

	// major versions
	MajorVersions map[string]HashicorpCloudGlobalNetworkManager20220215ConsulMajorVersion `json:"major_versions,omitempty"`
}

// Validate validates this hashicorp cloud global network manager 20220215 list consul versions response
func (m *HashicorpCloudGlobalNetworkManager20220215ListConsulVersionsResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215ListConsulVersionsResponse) validateCves(formats strfmt.Registry) error {
	if swag.IsZero(m.Cves) { // not required
		return nil
	}

	for k := range m.Cves {

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

	}

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215ListConsulVersionsResponse) validateMajorVersions(formats strfmt.Registry) error {
	if swag.IsZero(m.MajorVersions) { // not required
		return nil
	}

	for k := range m.MajorVersions {

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

	}

	return nil
}

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

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215ListConsulVersionsResponse) contextValidateCves(ctx context.Context, formats strfmt.Registry) error {

	for k := range m.Cves {

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

	}

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215ListConsulVersionsResponse) contextValidateMajorVersions(ctx context.Context, formats strfmt.Registry) error {

	for k := range m.MajorVersions {

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

	}

	return nil
}

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

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