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

package models

import (
	"context"
	stderrors "errors"
	"strconv"

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

// ExamplepbABitOfEverythingRepeated ABitOfEverythingRepeated is used to validate repeated path parameter functionality
// Example: {"path_repeated_bool_value":[true,true,false,true],"path_repeated_int32_value":[1,2,3]}
//
// swagger:model examplepbABitOfEverythingRepeated
type ExamplepbABitOfEverythingRepeated struct {

	// path repeated bool value
	PathRepeatedBoolValue []bool `json:"pathRepeatedBoolValue"`

	// path repeated bytes value
	PathRepeatedBytesValue []strfmt.Base64 `json:"pathRepeatedBytesValue"`

	// path repeated double value
	PathRepeatedDoubleValue []float64 `json:"pathRepeatedDoubleValue"`

	// path repeated enum value
	PathRepeatedEnumValue []*ExamplepbNumericEnum `json:"pathRepeatedEnumValue"`

	// path repeated fixed32 value
	PathRepeatedFixed32Value []int64 `json:"pathRepeatedFixed32Value"`

	// path repeated fixed64 value
	PathRepeatedFixed64Value []string `json:"pathRepeatedFixed64Value"`

	// repeated values. they are comma-separated in path
	PathRepeatedFloatValue []float32 `json:"pathRepeatedFloatValue"`

	// path repeated int32 value
	PathRepeatedInt32Value []int32 `json:"pathRepeatedInt32Value"`

	// path repeated int64 value
	PathRepeatedInt64Value []string `json:"pathRepeatedInt64Value"`

	// path repeated sfixed32 value
	PathRepeatedSfixed32Value []int32 `json:"pathRepeatedSfixed32Value"`

	// path repeated sfixed64 value
	PathRepeatedSfixed64Value []string `json:"pathRepeatedSfixed64Value"`

	// path repeated sint32 value
	PathRepeatedSint32Value []int32 `json:"pathRepeatedSint32Value"`

	// path repeated sint64 value
	PathRepeatedSint64Value []string `json:"pathRepeatedSint64Value"`

	// path repeated string value
	PathRepeatedStringValue []string `json:"pathRepeatedStringValue"`

	// path repeated uint32 value
	PathRepeatedUint32Value []int64 `json:"pathRepeatedUint32Value"`

	// path repeated uint64 value
	PathRepeatedUint64Value []string `json:"pathRepeatedUint64Value"`
}

// Validate validates this examplepb a bit of everything repeated
func (m *ExamplepbABitOfEverythingRepeated) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *ExamplepbABitOfEverythingRepeated) validatePathRepeatedEnumValue(formats strfmt.Registry) error {
	if swag.IsZero(m.PathRepeatedEnumValue) { // not required
		return nil
	}

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

		if m.PathRepeatedEnumValue[i] != nil {
			if err := m.PathRepeatedEnumValue[i].Validate(formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("pathRepeatedEnumValue" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("pathRepeatedEnumValue" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this examplepb a bit of everything repeated based on the context it is used
func (m *ExamplepbABitOfEverythingRepeated) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *ExamplepbABitOfEverythingRepeated) contextValidatePathRepeatedEnumValue(ctx context.Context, formats strfmt.Registry) error {

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

		if m.PathRepeatedEnumValue[i] != nil {

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

			if err := m.PathRepeatedEnumValue[i].ContextValidate(ctx, formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("pathRepeatedEnumValue" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("pathRepeatedEnumValue" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

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

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