package dc_cluster_group

import (
	"context"
	"fmt"
	"strings"

	"github.com/gogo/protobuf/proto"

	"gopkg.volterra.us/stdlib/codec"
	"gopkg.volterra.us/stdlib/db"
	"gopkg.volterra.us/stdlib/errors"
)

var (

	_ db.Interface
	_ = errors.Wrap
	_ = strings.Split
)

func (m *MetricData) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricData) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricData) DeepCopy() *MetricData {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricData{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricData) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricData) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricDataValidator().Validate(ctx, m, opts...)
}

type ValidateMetricData struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricData) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricData)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricData got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["data"]; exists {

		vOpts := append(opts, db.WithValidateField("data"))
		for idx, item := range m.GetData() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	if fv, exists := v.FldValidators["type"]; exists {

		vOpts := append(opts, db.WithValidateField("type"))
		if err := fv(ctx, m.GetType(), vOpts...); err != nil {
			return err
		}

	}

	return nil
}

var DefaultMetricDataValidator = func() *ValidateMetricData {
	v := &ValidateMetricData{FldValidators: map[string]db.ValidatorFunc{}}

	return v
}()

func MetricDataValidator() db.Validator {
	return DefaultMetricDataValidator
}

func (m *MetricTypeData) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricTypeData) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricTypeData) DeepCopy() *MetricTypeData {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricTypeData{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricTypeData) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricTypeData) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricTypeDataValidator().Validate(ctx, m, opts...)
}

type ValidateMetricTypeData struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricTypeData) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricTypeData)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricTypeData got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["key"]; exists {

		vOpts := append(opts, db.WithValidateField("key"))
		for key, value := range m.GetKey() {
			vOpts := append(vOpts, db.WithValidateMapKey(key))
			if err := fv(ctx, value, vOpts...); err != nil {
				return err
			}
		}

	}

	if fv, exists := v.FldValidators["value"]; exists {

		vOpts := append(opts, db.WithValidateField("value"))
		for idx, item := range m.GetValue() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	return nil
}

var DefaultMetricTypeDataValidator = func() *ValidateMetricTypeData {
	v := &ValidateMetricTypeData{FldValidators: map[string]db.ValidatorFunc{}}

	return v
}()

func MetricTypeDataValidator() db.Validator {
	return DefaultMetricTypeDataValidator
}

func (m *MetricsRequest) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricsRequest) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricsRequest) DeepCopy() *MetricsRequest {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricsRequest{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricsRequest) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricsRequest) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricsRequestValidator().Validate(ctx, m, opts...)
}

type ValidateMetricsRequest struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricsRequest) FieldSelectorValidationRuleHandler(rules map[string]string) (db.ValidatorFunc, error) {

	itemRules := db.GetRepEnumItemRules(rules)
	var conv db.EnumConvFn
	conv = func(v interface{}) int32 {
		i := v.(MetricType)
		return int32(i)
	}

	itemValFn, err := db.NewEnumValidationRuleHandler(itemRules, MetricType_name, conv)
	if err != nil {
		return nil, errors.Wrap(err, "ValidationRuleHandler for field_selector")
	}
	itemsValidatorFn := func(ctx context.Context, elems []MetricType, opts ...db.ValidateOpt) error {
		for i, el := range elems {
			if err := itemValFn(ctx, el, opts...); err != nil {
				return errors.Wrap(err, fmt.Sprintf("element %d", i))
			}
		}
		return nil
	}
	repValFn, err := db.NewRepeatedValidationRuleHandler(rules)
	if err != nil {
		return nil, errors.Wrap(err, "Repeated ValidationRuleHandler for field_selector")
	}

	validatorFn := func(ctx context.Context, val interface{}, opts ...db.ValidateOpt) error {
		elems, ok := val.([]MetricType)
		if !ok {
			return fmt.Errorf("Repeated validation expected []MetricType, got %T", val)
		}
		l := []string{}
		for _, elem := range elems {
			strVal := fmt.Sprintf("%v", elem)
			l = append(l, strVal)
		}
		if err := repValFn(ctx, l, opts...); err != nil {
			return errors.Wrap(err, "repeated field_selector")
		}
		if err := itemsValidatorFn(ctx, elems, opts...); err != nil {
			return errors.Wrap(err, "items field_selector")
		}
		return nil
	}

	return validatorFn, nil
}

func (v *ValidateMetricsRequest) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricsRequest)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricsRequest got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["end_time"]; exists {

		vOpts := append(opts, db.WithValidateField("end_time"))
		if err := fv(ctx, m.GetEndTime(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["field_selector"]; exists {
		vOpts := append(opts, db.WithValidateField("field_selector"))
		if err := fv(ctx, m.GetFieldSelector(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["filter"]; exists {

		vOpts := append(opts, db.WithValidateField("filter"))
		if err := fv(ctx, m.GetFilter(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["group_by"]; exists {

		vOpts := append(opts, db.WithValidateField("group_by"))
		for idx, item := range m.GetGroupBy() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	if fv, exists := v.FldValidators["namespace"]; exists {

		vOpts := append(opts, db.WithValidateField("namespace"))
		if err := fv(ctx, m.GetNamespace(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["range"]; exists {

		vOpts := append(opts, db.WithValidateField("range"))
		if err := fv(ctx, m.GetRange(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["start_time"]; exists {

		vOpts := append(opts, db.WithValidateField("start_time"))
		if err := fv(ctx, m.GetStartTime(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["step"]; exists {

		vOpts := append(opts, db.WithValidateField("step"))
		if err := fv(ctx, m.GetStep(), vOpts...); err != nil {
			return err
		}

	}

	return nil
}

var DefaultMetricsRequestValidator = func() *ValidateMetricsRequest {
	v := &ValidateMetricsRequest{FldValidators: map[string]db.ValidatorFunc{}}

	var (
		err error
		vFn db.ValidatorFunc
	)
	_, _ = err, vFn
	vFnMap := map[string]db.ValidatorFunc{}
	_ = vFnMap

	vrhFieldSelector := v.FieldSelectorValidationRuleHandler
	rulesFieldSelector := map[string]string{
		"ves.io.schema.rules.message.required": "true",
	}
	vFn, err = vrhFieldSelector(rulesFieldSelector)
	if err != nil {
		errMsg := fmt.Sprintf("ValidationRuleHandler for MetricsRequest.field_selector: %s", err)
		panic(errMsg)
	}
	v.FldValidators["field_selector"] = vFn

	return v
}()

func MetricsRequestValidator() db.Validator {
	return DefaultMetricsRequestValidator
}

func (m *MetricsResponse) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricsResponse) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricsResponse) DeepCopy() *MetricsResponse {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricsResponse{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricsResponse) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricsResponse) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricsResponseValidator().Validate(ctx, m, opts...)
}

type ValidateMetricsResponse struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricsResponse) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricsResponse)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricsResponse got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["data"]; exists {

		vOpts := append(opts, db.WithValidateField("data"))
		for idx, item := range m.GetData() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	return nil
}

var DefaultMetricsResponseValidator = func() *ValidateMetricsResponse {
	v := &ValidateMetricsResponse{FldValidators: map[string]db.ValidatorFunc{}}

	return v
}()

func MetricsResponseValidator() db.Validator {
	return DefaultMetricsResponseValidator
}
//
// Copyright (c) 2018 Volterra, Inc. All rights reserved.
// Code generated by ves-gen-schema-go. DO NOT EDIT.
//
package dc_cluster_group

import (
	"context"
	"fmt"
	"strings"

	"github.com/gogo/protobuf/proto"

	"gopkg.volterra.us/stdlib/codec"
	"gopkg.volterra.us/stdlib/db"
	"gopkg.volterra.us/stdlib/errors"
)

var (
	// dummy imports in case file has no message with Refs
	_ db.Interface
	_ = errors.Wrap
	_ = strings.Split
)

// augmented methods on protoc/std generated struct

func (m *MetricData) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricData) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricData) DeepCopy() *MetricData {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricData{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricData) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricData) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricDataValidator().Validate(ctx, m, opts...)
}

type ValidateMetricData struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricData) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricData)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricData got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["data"]; exists {

		vOpts := append(opts, db.WithValidateField("data"))
		for idx, item := range m.GetData() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	if fv, exists := v.FldValidators["type"]; exists {

		vOpts := append(opts, db.WithValidateField("type"))
		if err := fv(ctx, m.GetType(), vOpts...); err != nil {
			return err
		}

	}

	return nil
}

// Well-known symbol for default validator implementation
var DefaultMetricDataValidator = func() *ValidateMetricData {
	v := &ValidateMetricData{FldValidators: map[string]db.ValidatorFunc{}}

	return v
}()

func MetricDataValidator() db.Validator {
	return DefaultMetricDataValidator
}

// augmented methods on protoc/std generated struct

func (m *MetricTypeData) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricTypeData) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricTypeData) DeepCopy() *MetricTypeData {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricTypeData{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricTypeData) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricTypeData) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricTypeDataValidator().Validate(ctx, m, opts...)
}

type ValidateMetricTypeData struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricTypeData) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricTypeData)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricTypeData got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["key"]; exists {

		vOpts := append(opts, db.WithValidateField("key"))
		for key, value := range m.GetKey() {
			vOpts := append(vOpts, db.WithValidateMapKey(key))
			if err := fv(ctx, value, vOpts...); err != nil {
				return err
			}
		}

	}

	if fv, exists := v.FldValidators["value"]; exists {

		vOpts := append(opts, db.WithValidateField("value"))
		for idx, item := range m.GetValue() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	return nil
}

// Well-known symbol for default validator implementation
var DefaultMetricTypeDataValidator = func() *ValidateMetricTypeData {
	v := &ValidateMetricTypeData{FldValidators: map[string]db.ValidatorFunc{}}

	return v
}()

func MetricTypeDataValidator() db.Validator {
	return DefaultMetricTypeDataValidator
}

// augmented methods on protoc/std generated struct

func (m *MetricsRequest) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricsRequest) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricsRequest) DeepCopy() *MetricsRequest {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricsRequest{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricsRequest) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricsRequest) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricsRequestValidator().Validate(ctx, m, opts...)
}

type ValidateMetricsRequest struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricsRequest) FieldSelectorValidationRuleHandler(rules map[string]string) (db.ValidatorFunc, error) {

	itemRules := db.GetRepEnumItemRules(rules)
	var conv db.EnumConvFn
	conv = func(v interface{}) int32 {
		i := v.(MetricType)
		return int32(i)
	}
	// MetricType_name is generated in .pb.go
	itemValFn, err := db.NewEnumValidationRuleHandler(itemRules, MetricType_name, conv)
	if err != nil {
		return nil, errors.Wrap(err, "ValidationRuleHandler for field_selector")
	}
	itemsValidatorFn := func(ctx context.Context, elems []MetricType, opts ...db.ValidateOpt) error {
		for i, el := range elems {
			if err := itemValFn(ctx, el, opts...); err != nil {
				return errors.Wrap(err, fmt.Sprintf("element %d", i))
			}
		}
		return nil
	}
	repValFn, err := db.NewRepeatedValidationRuleHandler(rules)
	if err != nil {
		return nil, errors.Wrap(err, "Repeated ValidationRuleHandler for field_selector")
	}

	validatorFn := func(ctx context.Context, val interface{}, opts ...db.ValidateOpt) error {
		elems, ok := val.([]MetricType)
		if !ok {
			return fmt.Errorf("Repeated validation expected []MetricType, got %T", val)
		}
		l := []string{}
		for _, elem := range elems {
			strVal := fmt.Sprintf("%v", elem)
			l = append(l, strVal)
		}
		if err := repValFn(ctx, l, opts...); err != nil {
			return errors.Wrap(err, "repeated field_selector")
		}
		if err := itemsValidatorFn(ctx, elems, opts...); err != nil {
			return errors.Wrap(err, "items field_selector")
		}
		return nil
	}

	return validatorFn, nil
}

func (v *ValidateMetricsRequest) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricsRequest)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricsRequest got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["end_time"]; exists {

		vOpts := append(opts, db.WithValidateField("end_time"))
		if err := fv(ctx, m.GetEndTime(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["field_selector"]; exists {
		vOpts := append(opts, db.WithValidateField("field_selector"))
		if err := fv(ctx, m.GetFieldSelector(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["filter"]; exists {

		vOpts := append(opts, db.WithValidateField("filter"))
		if err := fv(ctx, m.GetFilter(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["group_by"]; exists {

		vOpts := append(opts, db.WithValidateField("group_by"))
		for idx, item := range m.GetGroupBy() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	if fv, exists := v.FldValidators["namespace"]; exists {

		vOpts := append(opts, db.WithValidateField("namespace"))
		if err := fv(ctx, m.GetNamespace(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["range"]; exists {

		vOpts := append(opts, db.WithValidateField("range"))
		if err := fv(ctx, m.GetRange(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["start_time"]; exists {

		vOpts := append(opts, db.WithValidateField("start_time"))
		if err := fv(ctx, m.GetStartTime(), vOpts...); err != nil {
			return err
		}

	}

	if fv, exists := v.FldValidators["step"]; exists {

		vOpts := append(opts, db.WithValidateField("step"))
		if err := fv(ctx, m.GetStep(), vOpts...); err != nil {
			return err
		}

	}

	return nil
}

// Well-known symbol for default validator implementation
var DefaultMetricsRequestValidator = func() *ValidateMetricsRequest {
	v := &ValidateMetricsRequest{FldValidators: map[string]db.ValidatorFunc{}}

	var (
		err error
		vFn db.ValidatorFunc
	)
	_, _ = err, vFn
	vFnMap := map[string]db.ValidatorFunc{}
	_ = vFnMap

	vrhFieldSelector := v.FieldSelectorValidationRuleHandler
	rulesFieldSelector := map[string]string{
		"ves.io.schema.rules.message.required": "true",
	}
	vFn, err = vrhFieldSelector(rulesFieldSelector)
	if err != nil {
		errMsg := fmt.Sprintf("ValidationRuleHandler for MetricsRequest.field_selector: %s", err)
		panic(errMsg)
	}
	v.FldValidators["field_selector"] = vFn

	return v
}()

func MetricsRequestValidator() db.Validator {
	return DefaultMetricsRequestValidator
}

// augmented methods on protoc/std generated struct

func (m *MetricsResponse) ToJSON() (string, error) {
	return codec.ToJSON(m)
}

func (m *MetricsResponse) ToYAML() (string, error) {
	return codec.ToYAML(m)
}

func (m *MetricsResponse) DeepCopy() *MetricsResponse {
	if m == nil {
		return nil
	}
	ser, err := m.Marshal()
	if err != nil {
		return nil
	}
	c := &MetricsResponse{}
	err = c.Unmarshal(ser)
	if err != nil {
		return nil
	}
	return c
}

func (m *MetricsResponse) DeepCopyProto() proto.Message {
	if m == nil {
		return nil
	}
	return m.DeepCopy()
}

func (m *MetricsResponse) Validate(ctx context.Context, opts ...db.ValidateOpt) error {
	return MetricsResponseValidator().Validate(ctx, m, opts...)
}

type ValidateMetricsResponse struct {
	FldValidators map[string]db.ValidatorFunc
}

func (v *ValidateMetricsResponse) Validate(ctx context.Context, pm interface{}, opts ...db.ValidateOpt) error {
	m, ok := pm.(*MetricsResponse)
	if !ok {
		switch t := pm.(type) {
		case nil:
			return nil
		default:
			return fmt.Errorf("Expected type *MetricsResponse got type %s", t)
		}
	}
	if m == nil {
		return nil
	}

	if fv, exists := v.FldValidators["data"]; exists {

		vOpts := append(opts, db.WithValidateField("data"))
		for idx, item := range m.GetData() {
			vOpts := append(vOpts, db.WithValidateRepItem(idx))
			if err := fv(ctx, item, vOpts...); err != nil {
				return err
			}
		}

	}

	return nil
}

// Well-known symbol for default validator implementation
var DefaultMetricsResponseValidator = func() *ValidateMetricsResponse {
	v := &ValidateMetricsResponse{FldValidators: map[string]db.ValidatorFunc{}}

	return v
}()

func MetricsResponseValidator() db.Validator {
	return DefaultMetricsResponseValidator
}
