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

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

// EntityConfigPairs entity config pairs
//
// swagger:model entity.ConfigPairs
type EntityConfigPairs struct {

	// config pair map
	ConfigPairMap map[string]EntityConfigPair `json:"config_pair_map,omitempty"`

	// creation timestamp unix
	CreationTimestampUnix int64 `json:"creation_timestamp_unix,omitempty"`
}

// Validate validates this entity config pairs
func (m *EntityConfigPairs) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *EntityConfigPairs) validateConfigPairMap(formats strfmt.Registry) error {
	if swag.IsZero(m.ConfigPairMap) { // not required
		return nil
	}

	for k := range m.ConfigPairMap {

		if err := validate.Required("config_pair_map"+"."+k, "body", m.ConfigPairMap[k]); err != nil {
			return err
		}
		if val, ok := m.ConfigPairMap[k]; ok {
			if err := val.Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("config_pair_map" + "." + k)
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("config_pair_map" + "." + k)
				}
				return err
			}
		}

	}

	return nil
}

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

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

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

func (m *EntityConfigPairs) contextValidateConfigPairMap(ctx context.Context, formats strfmt.Registry) error {

	for k := range m.ConfigPairMap {

		if val, ok := m.ConfigPairMap[k]; ok {
			if err := val.ContextValidate(ctx, formats); err != nil {
				return err
			}
		}

	}

	return nil
}

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

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