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

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

// VolumeGroupRemoteCopyRelationships volume group remote copy relationships
//
// swagger:model VolumeGroupRemoteCopyRelationships
type VolumeGroupRemoteCopyRelationships struct {

	// The ID of the volume group
	ID string `json:"id,omitempty"`

	// List of remote copy relationships
	RemoteCopyRelationships []*RemoteCopyRelationship `json:"remoteCopyRelationships"`
}

// Validate validates this volume group remote copy relationships
func (m *VolumeGroupRemoteCopyRelationships) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *VolumeGroupRemoteCopyRelationships) validateRemoteCopyRelationships(formats strfmt.Registry) error {
	if swag.IsZero(m.RemoteCopyRelationships) { // not required
		return nil
	}

	for i := 0; i < len(m.RemoteCopyRelationships); i++ {
		if swag.IsZero(m.RemoteCopyRelationships[i]) { // not required
			continue
		}

		if m.RemoteCopyRelationships[i] != nil {
			if err := m.RemoteCopyRelationships[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("remoteCopyRelationships" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("remoteCopyRelationships" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this volume group remote copy relationships based on the context it is used
func (m *VolumeGroupRemoteCopyRelationships) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *VolumeGroupRemoteCopyRelationships) contextValidateRemoteCopyRelationships(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.RemoteCopyRelationships); i++ {

		if m.RemoteCopyRelationships[i] != nil {

			if swag.IsZero(m.RemoteCopyRelationships[i]) { // not required
				return nil
			}

			if err := m.RemoteCopyRelationships[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("remoteCopyRelationships" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("remoteCopyRelationships" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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