// Code generated by go-swagger; DO NOT EDIT.

package ops

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"strconv"

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

// DashboardSLOInfoResp dashboard s l o info resp
//
// swagger:model dashboard.SLOInfoResp
type DashboardSLOInfoResp struct {

	// current summary
	CurrentSummary []*EntityApplicationSLOSummary `json:"currentSummary"`
}

// Validate validates this dashboard s l o info resp
func (m *DashboardSLOInfoResp) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *DashboardSLOInfoResp) validateCurrentSummary(formats strfmt.Registry) error {
	if swag.IsZero(m.CurrentSummary) { // not required
		return nil
	}

	for i := 0; i < len(m.CurrentSummary); i++ {
		if swag.IsZero(m.CurrentSummary[i]) { // not required
			continue
		}

		if m.CurrentSummary[i] != nil {
			if err := m.CurrentSummary[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("currentSummary" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("currentSummary" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this dashboard s l o info resp based on the context it is used
func (m *DashboardSLOInfoResp) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *DashboardSLOInfoResp) contextValidateCurrentSummary(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.CurrentSummary); i++ {

		if m.CurrentSummary[i] != nil {

			if swag.IsZero(m.CurrentSummary[i]) { // not required
				return nil
			}

			if err := m.CurrentSummary[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("currentSummary" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("currentSummary" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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