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

// HostProgress host progress
//
// swagger:model host-progress
type HostProgress struct {

	// current stage
	CurrentStage HostStage `json:"current_stage,omitempty"`

	// progress info
	ProgressInfo string `json:"progress_info,omitempty" gorm:"type:varchar(2048)"`
}

// Validate validates this host progress
func (m *HostProgress) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HostProgress) validateCurrentStage(formats strfmt.Registry) error {
	if swag.IsZero(m.CurrentStage) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this host progress based on the context it is used
func (m *HostProgress) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HostProgress) contextValidateCurrentStage(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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