// 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"
	alternate "github.com/go-swagger/go-swagger/examples/external-types/fred"
)

// MyCustomArray This generate an array type in models, based on the external type.
//
// []alternate.MyAlternateType
//
// The validation method of the external type is called by the generated array.
//
// swagger:model MyCustomArray
type MyCustomArray []alternate.MyAlternateType

// Validate validates this my custom array
func (m MyCustomArray) Validate(formats strfmt.Registry) error {
	var res []error

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

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

			return err
		}

	}

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

// ContextValidate validates this my custom array based on context it is used
func (m MyCustomArray) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}
