// 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"
)

// HandlersFleetVehicleParams handlers fleet vehicle params
//
// swagger:model handlers.FleetVehicleParams
type HandlersFleetVehicleParams struct {

	// canbus
	Canbus *CommonCANBus `json:"canbus,omitempty"`

	// idps enabled
	IdpsEnabled bool `json:"idps_enabled,omitempty"`

	// log level
	LogLevel string `json:"log_level,omitempty"`

	// vin
	Vin string `json:"vin,omitempty"`

	// vins
	Vins []string `json:"vins"`
}

// Validate validates this handlers fleet vehicle params
func (m *HandlersFleetVehicleParams) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HandlersFleetVehicleParams) validateCanbus(formats strfmt.Registry) error {
	if swag.IsZero(m.Canbus) { // not required
		return nil
	}

	if m.Canbus != nil {
		if err := m.Canbus.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("canbus")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("canbus")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this handlers fleet vehicle params based on the context it is used
func (m *HandlersFleetVehicleParams) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HandlersFleetVehicleParams) contextValidateCanbus(ctx context.Context, formats strfmt.Registry) error {

	if m.Canbus != nil {

		if swag.IsZero(m.Canbus) { // not required
			return nil
		}

		if err := m.Canbus.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("canbus")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("canbus")
			}
			return err
		}
	}

	return nil
}

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

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