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

package models

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

import (
	"strconv"

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

// CentralLastError central last error
//
// swagger:model centralLastError
type CentralLastError struct {

	// codes
	// Required: true
	Codes []CentralInfraErrorCode `json:"codes"`
}

// Validate validates this central last error
func (m *CentralLastError) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *CentralLastError) validateCodes(formats strfmt.Registry) error {

	if err := validate.Required("codes", "body", m.Codes); err != nil {
		return err
	}

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

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

	}

	return nil
}

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

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