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

// HashicorpCloudResourcemanagerCheckResult Result of an individual check.
//
// swagger:model hashicorp.cloud.resourcemanager.CheckResult
type HashicorpCloudResourcemanagerCheckResult struct {

	// Stable identifier for the check.
	CheckID *HashicorpCloudResourcemanagerCheckID `json:"check_id,omitempty"`

	// Reasons for the failure, the check did not pass
	FailureDetails *HashicorpCloudResourcemanagerFailureDetails `json:"failure_details,omitempty"`

	// Status of the check: PASS, FAIL, or UNKNOWN.
	Status *HashicorpCloudResourcemanagerCheckStatus `json:"status,omitempty"`
}

// Validate validates this hashicorp cloud resourcemanager check result
func (m *HashicorpCloudResourcemanagerCheckResult) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudResourcemanagerCheckResult) validateCheckID(formats strfmt.Registry) error {
	if swag.IsZero(m.CheckID) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudResourcemanagerCheckResult) validateFailureDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.FailureDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudResourcemanagerCheckResult) validateStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.Status) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud resourcemanager check result based on the context it is used
func (m *HashicorpCloudResourcemanagerCheckResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudResourcemanagerCheckResult) contextValidateCheckID(ctx context.Context, formats strfmt.Registry) error {

	if m.CheckID != nil {

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

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

	return nil
}

func (m *HashicorpCloudResourcemanagerCheckResult) contextValidateFailureDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.FailureDetails != nil {

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

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

	return nil
}

func (m *HashicorpCloudResourcemanagerCheckResult) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.Status != nil {

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

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

	return nil
}

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

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