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

// HashicorpCloudNetwork20200907CreateDNSForwardingRuleRequest CreateDNSForwardingRuleRequest is a request type for CreateDNSForwardingRule endpoint
//
// swagger:model hashicorp.cloud.network_20200907.CreateDNSForwardingRuleRequest
type HashicorpCloudNetwork20200907CreateDNSForwardingRuleRequest struct {

	// DNSForwardingRule is the dnsForwardingRule to be created.
	DNSForwardingRule *HashicorpCloudNetwork20200907DNSForwardingRule `json:"dns_forwarding_rule,omitempty"`
}

// Validate validates this hashicorp cloud network 20200907 create DNS forwarding rule request
func (m *HashicorpCloudNetwork20200907CreateDNSForwardingRuleRequest) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudNetwork20200907CreateDNSForwardingRuleRequest) validateDNSForwardingRule(formats strfmt.Registry) error {
	if swag.IsZero(m.DNSForwardingRule) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud network 20200907 create DNS forwarding rule request based on the context it is used
func (m *HashicorpCloudNetwork20200907CreateDNSForwardingRuleRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudNetwork20200907CreateDNSForwardingRuleRequest) contextValidateDNSForwardingRule(ctx context.Context, formats strfmt.Registry) error {

	if m.DNSForwardingRule != nil {

		if swag.IsZero(m.DNSForwardingRule) { // not required
			return nil
		}

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

	return nil
}

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

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