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

// ReportDashboard report dashboard
//
// swagger:model ReportDashboard
type ReportDashboard struct {

	// dashboard
	Dashboard *ReportDashboardID `json:"dashboard,omitempty"`

	// report variables
	ReportVariables interface{} `json:"reportVariables,omitempty"`

	// time range
	TimeRange *ReportTimeRange `json:"timeRange,omitempty"`
}

// Validate validates this report dashboard
func (m *ReportDashboard) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *ReportDashboard) validateDashboard(formats strfmt.Registry) error {
	if swag.IsZero(m.Dashboard) { // not required
		return nil
	}

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

	return nil
}

func (m *ReportDashboard) validateTimeRange(formats strfmt.Registry) error {
	if swag.IsZero(m.TimeRange) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

func (m *ReportDashboard) contextValidateDashboard(ctx context.Context, formats strfmt.Registry) error {

	if m.Dashboard != nil {

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

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

	return nil
}

func (m *ReportDashboard) contextValidateTimeRange(ctx context.Context, formats strfmt.Registry) error {

	if m.TimeRange != nil {

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

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

	return nil
}

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

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