// 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"
	"encoding/json"

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

// CalculateDashboardDiffParamsBody calculate dashboard diff params body
//
// swagger:model calculateDashboardDiffParamsBody
type CalculateDashboardDiffParamsBody struct {

	// base
	Base *CalculateDiffTarget `json:"base,omitempty"`

	// The type of diff to return
	// Description:
	// `basic`
	// `json`
	// Enum: [basic json]
	DiffType string `json:"diffType,omitempty"`

	// new
	New *CalculateDiffTarget `json:"new,omitempty"`
}

// Validate validates this calculate dashboard diff params body
func (m *CalculateDashboardDiffParamsBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *CalculateDashboardDiffParamsBody) validateBase(formats strfmt.Registry) error {
	if swag.IsZero(m.Base) { // not required
		return nil
	}

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

	return nil
}

var calculateDashboardDiffParamsBodyTypeDiffTypePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["basic","json"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		calculateDashboardDiffParamsBodyTypeDiffTypePropEnum = append(calculateDashboardDiffParamsBodyTypeDiffTypePropEnum, v)
	}
}

const (

	// CalculateDashboardDiffParamsBodyDiffTypeBasic captures enum value "basic"
	CalculateDashboardDiffParamsBodyDiffTypeBasic string = "basic"

	// CalculateDashboardDiffParamsBodyDiffTypeJSON captures enum value "json"
	CalculateDashboardDiffParamsBodyDiffTypeJSON string = "json"
)

// prop value enum
func (m *CalculateDashboardDiffParamsBody) validateDiffTypeEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, calculateDashboardDiffParamsBodyTypeDiffTypePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CalculateDashboardDiffParamsBody) validateDiffType(formats strfmt.Registry) error {
	if swag.IsZero(m.DiffType) { // not required
		return nil
	}

	// value enum
	if err := m.validateDiffTypeEnum("diffType", "body", m.DiffType); err != nil {
		return err
	}

	return nil
}

func (m *CalculateDashboardDiffParamsBody) validateNew(formats strfmt.Registry) error {
	if swag.IsZero(m.New) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this calculate dashboard diff params body based on the context it is used
func (m *CalculateDashboardDiffParamsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *CalculateDashboardDiffParamsBody) contextValidateBase(ctx context.Context, formats strfmt.Registry) error {

	if m.Base != nil {

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

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

	return nil
}

func (m *CalculateDashboardDiffParamsBody) contextValidateNew(ctx context.Context, formats strfmt.Registry) error {

	if m.New != nil {

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

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

	return nil
}

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

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