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

// CommonCarState common car state
//
// swagger:model common.CarState
type CommonCarState struct {

	// ambient temperature
	AmbientTemperature *CommonAmbientTemperature `json:"ambient_temperature,omitempty"`

	// battery
	Battery *CommonBattery `json:"battery,omitempty"`

	// cabin climate
	CabinClimate *CommonCabinClimate `json:"cabin_climate,omitempty"`

	// cell temp
	CellTemp *CommonCellTemperature `json:"cell_temp,omitempty"`

	// charging metrics
	ChargingMetrics *CommonVCUChargingMetrics `json:"charging_metrics,omitempty"`

	// charging status
	ChargingStatus int64 `json:"charging_status,omitempty"`

	// dbc version
	DbcVersion string `json:"dbc_version,omitempty"`

	// door locks
	DoorLocks *CommonLocks `json:"door_locks,omitempty"`

	// doors
	Doors *CommonDoors `json:"doors,omitempty"`

	// driver occupy seat state
	DriverOccupySeatState int64 `json:"driver_occupy_seat_state,omitempty"`

	// driver seat heat
	DriverSeatHeat *CommonDriverSeatHeat `json:"driver_seat_heat,omitempty"`

	// expanded signals
	ExpandedSignals *CommonExpandedSignals `json:"expanded_signals,omitempty"`

	// gear
	Gear *CommonGear `json:"gear,omitempty"`

	// ip
	IP string `json:"ip,omitempty"`

	// location
	Location *CommonLocation `json:"location,omitempty"`

	// max range
	MaxRange *CommonMaxRange `json:"max_range,omitempty"`

	// misc windows
	MiscWindows *CommonMiscWindows `json:"misc_windows,omitempty"`

	// online
	Online bool `json:"online,omitempty"`

	// online hmi
	OnlineHmi bool `json:"online_hmi,omitempty"`

	// passenger seat heat
	PassengerSeatHeat *CommonPassengerSeatHeat `json:"passenger_seat_heat,omitempty"`

	// power mode
	PowerMode int64 `json:"power_mode,omitempty"`

	// rear defrost
	RearDefrost *CommonRearDefrost `json:"rear_defrost,omitempty"`

	// safe state
	SafeState *CommonSafeState `json:"safe_state,omitempty"`

	// state of charge
	StateOfCharge *CommonStateOfCharge `json:"state_of_charge,omitempty"`

	// steering wheel heat
	SteeringWheelHeat *CommonSteeringWheelHeat `json:"steering_wheel_heat,omitempty"`

	// sunroof
	Sunroof *CommonSunroof `json:"sunroof,omitempty"`

	// trex version
	TrexVersion string `json:"trex_version,omitempty"`

	// updated
	Updated string `json:"updated,omitempty"`

	// vcu0x260
	Vcu0x260 *CommonVCU0x260Descriptor `json:"vcu0x260,omitempty"`

	// vcucharging status
	VcuchargingStatus *CommonVCUChargingStatus `json:"vcucharging_status,omitempty"`

	// vehicle ready state
	VehicleReadyState *CommonVehicleReadyState `json:"vehicle_ready_state,omitempty"`

	// vehicle speed
	VehicleSpeed *CommonVehicleSpeed `json:"vehicle_speed,omitempty"`

	// windows
	Windows *CommonWindows `json:"windows,omitempty"`
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *CommonCarState) validateAmbientTemperature(formats strfmt.Registry) error {
	if swag.IsZero(m.AmbientTemperature) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateBattery(formats strfmt.Registry) error {
	if swag.IsZero(m.Battery) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateCabinClimate(formats strfmt.Registry) error {
	if swag.IsZero(m.CabinClimate) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateCellTemp(formats strfmt.Registry) error {
	if swag.IsZero(m.CellTemp) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateChargingMetrics(formats strfmt.Registry) error {
	if swag.IsZero(m.ChargingMetrics) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateDoorLocks(formats strfmt.Registry) error {
	if swag.IsZero(m.DoorLocks) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateDoors(formats strfmt.Registry) error {
	if swag.IsZero(m.Doors) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateDriverSeatHeat(formats strfmt.Registry) error {
	if swag.IsZero(m.DriverSeatHeat) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateExpandedSignals(formats strfmt.Registry) error {
	if swag.IsZero(m.ExpandedSignals) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateGear(formats strfmt.Registry) error {
	if swag.IsZero(m.Gear) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateLocation(formats strfmt.Registry) error {
	if swag.IsZero(m.Location) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateMaxRange(formats strfmt.Registry) error {
	if swag.IsZero(m.MaxRange) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateMiscWindows(formats strfmt.Registry) error {
	if swag.IsZero(m.MiscWindows) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validatePassengerSeatHeat(formats strfmt.Registry) error {
	if swag.IsZero(m.PassengerSeatHeat) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateRearDefrost(formats strfmt.Registry) error {
	if swag.IsZero(m.RearDefrost) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateSafeState(formats strfmt.Registry) error {
	if swag.IsZero(m.SafeState) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateStateOfCharge(formats strfmt.Registry) error {
	if swag.IsZero(m.StateOfCharge) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateSteeringWheelHeat(formats strfmt.Registry) error {
	if swag.IsZero(m.SteeringWheelHeat) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateSunroof(formats strfmt.Registry) error {
	if swag.IsZero(m.Sunroof) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateVcu0x260(formats strfmt.Registry) error {
	if swag.IsZero(m.Vcu0x260) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateVcuchargingStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.VcuchargingStatus) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateVehicleReadyState(formats strfmt.Registry) error {
	if swag.IsZero(m.VehicleReadyState) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateVehicleSpeed(formats strfmt.Registry) error {
	if swag.IsZero(m.VehicleSpeed) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonCarState) validateWindows(formats strfmt.Registry) error {
	if swag.IsZero(m.Windows) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this common car state based on the context it is used
func (m *CommonCarState) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *CommonCarState) contextValidateAmbientTemperature(ctx context.Context, formats strfmt.Registry) error {

	if m.AmbientTemperature != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateBattery(ctx context.Context, formats strfmt.Registry) error {

	if m.Battery != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateCabinClimate(ctx context.Context, formats strfmt.Registry) error {

	if m.CabinClimate != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateCellTemp(ctx context.Context, formats strfmt.Registry) error {

	if m.CellTemp != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateChargingMetrics(ctx context.Context, formats strfmt.Registry) error {

	if m.ChargingMetrics != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateDoorLocks(ctx context.Context, formats strfmt.Registry) error {

	if m.DoorLocks != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateDoors(ctx context.Context, formats strfmt.Registry) error {

	if m.Doors != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateDriverSeatHeat(ctx context.Context, formats strfmt.Registry) error {

	if m.DriverSeatHeat != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateExpandedSignals(ctx context.Context, formats strfmt.Registry) error {

	if m.ExpandedSignals != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateGear(ctx context.Context, formats strfmt.Registry) error {

	if m.Gear != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateLocation(ctx context.Context, formats strfmt.Registry) error {

	if m.Location != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateMaxRange(ctx context.Context, formats strfmt.Registry) error {

	if m.MaxRange != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateMiscWindows(ctx context.Context, formats strfmt.Registry) error {

	if m.MiscWindows != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidatePassengerSeatHeat(ctx context.Context, formats strfmt.Registry) error {

	if m.PassengerSeatHeat != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateRearDefrost(ctx context.Context, formats strfmt.Registry) error {

	if m.RearDefrost != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateSafeState(ctx context.Context, formats strfmt.Registry) error {

	if m.SafeState != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateStateOfCharge(ctx context.Context, formats strfmt.Registry) error {

	if m.StateOfCharge != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateSteeringWheelHeat(ctx context.Context, formats strfmt.Registry) error {

	if m.SteeringWheelHeat != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateSunroof(ctx context.Context, formats strfmt.Registry) error {

	if m.Sunroof != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateVcu0x260(ctx context.Context, formats strfmt.Registry) error {

	if m.Vcu0x260 != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateVcuchargingStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.VcuchargingStatus != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateVehicleReadyState(ctx context.Context, formats strfmt.Registry) error {

	if m.VehicleReadyState != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateVehicleSpeed(ctx context.Context, formats strfmt.Registry) error {

	if m.VehicleSpeed != nil {

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

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

	return nil
}

func (m *CommonCarState) contextValidateWindows(ctx context.Context, formats strfmt.Registry) error {

	if m.Windows != nil {

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

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

	return nil
}

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

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