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

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

// CommonCarUpdateProgress common car update progress
//
// swagger:model common.CarUpdateProgress
type CommonCarUpdateProgress struct {

	// car update id
	CarUpdateID int64 `json:"car_update_id,omitempty"`

	// ecu
	// Max Length: 100
	Ecu string `json:"ecu,omitempty"`

	// err
	Err int64 `json:"err,omitempty"`

	// extra info
	// Max Length: 1000
	ExtraInfo string `json:"extra_info,omitempty"`

	// file current
	FileCurrent int64 `json:"file_current,omitempty"`

	// file total
	FileTotal int64 `json:"file_total,omitempty"`

	// installed
	Installed int64 `json:"installed,omitempty"`

	// msg
	// Max Length: 1000
	Msg string `json:"msg,omitempty"`

	// package current
	PackageCurrent int64 `json:"package_current,omitempty"`

	// package total
	PackageTotal int64 `json:"package_total,omitempty"`

	// total files
	TotalFiles int64 `json:"total_files,omitempty"`
}

// Validate validates this common car update progress
func (m *CommonCarUpdateProgress) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *CommonCarUpdateProgress) validateEcu(formats strfmt.Registry) error {
	if swag.IsZero(m.Ecu) { // not required
		return nil
	}

	if err := validate.MaxLength("ecu", "body", m.Ecu, 100); err != nil {
		return err
	}

	return nil
}

func (m *CommonCarUpdateProgress) validateExtraInfo(formats strfmt.Registry) error {
	if swag.IsZero(m.ExtraInfo) { // not required
		return nil
	}

	if err := validate.MaxLength("extra_info", "body", m.ExtraInfo, 1000); err != nil {
		return err
	}

	return nil
}

func (m *CommonCarUpdateProgress) validateMsg(formats strfmt.Registry) error {
	if swag.IsZero(m.Msg) { // not required
		return nil
	}

	if err := validate.MaxLength("msg", "body", m.Msg, 1000); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this common car update progress based on context it is used
func (m *CommonCarUpdateProgress) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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