// 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" "encoding/json" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // CommonUpdateCarRequest common update car request // // swagger:model common.UpdateCarRequest type CommonUpdateCarRequest struct { // body type // Max Length: 256 BodyType string `json:"body_type,omitempty"` // canbus Canbus *CommonCANBus `json:"canbus,omitempty"` // country // Max Length: 256 Country string `json:"country,omitempty"` // debug mask DebugMask string `json:"debug_mask,omitempty"` // dlt enabled DltEnabled bool `json:"dlt_enabled,omitempty"` // dlt level // Enum: [0,1,2,3,4,5,6,255] DltLevel int64 `json:"dlt_level,omitempty"` // dtc ttl DtcTTL int64 `json:"dtc_ttl,omitempty"` // iccid // Max Length: 50 Iccid string `json:"iccid,omitempty"` // idps enabled IdpsEnabled bool `json:"idps_enabled,omitempty"` // log level LogLevel string `json:"log_level,omitempty"` // model // Required: true // Max Length: 256 Model *string `json:"model"` // powertrain // Max Length: 256 Powertrain string `json:"powertrain,omitempty"` // restraint // Max Length: 256 Restraint string `json:"restraint,omitempty"` // sums version SumsVersion string `json:"sums_version,omitempty"` // tags Tags []string `json:"tags"` // trim // Required: true // Max Length: 256 Trim *string `json:"trim"` // vin // Required: true Vin *string `json:"vin"` // year // Required: true // Maximum: 9999 // Minimum: 1000 Year *int64 `json:"year"` } // Validate validates this common update car request func (m *CommonUpdateCarRequest) Validate(formats strfmt.Registry) error { var res []error if err := m.validateBodyType(formats); err != nil { res = append(res, err) } if err := m.validateCanbus(formats); err != nil { res = append(res, err) } if err := m.validateCountry(formats); err != nil { res = append(res, err) } if err := m.validateDltLevel(formats); err != nil { res = append(res, err) } if err := m.validateIccid(formats); err != nil { res = append(res, err) } if err := m.validateModel(formats); err != nil { res = append(res, err) } if err := m.validatePowertrain(formats); err != nil { res = append(res, err) } if err := m.validateRestraint(formats); err != nil { res = append(res, err) } if err := m.validateTrim(formats); err != nil { res = append(res, err) } if err := m.validateVin(formats); err != nil { res = append(res, err) } if err := m.validateYear(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CommonUpdateCarRequest) validateBodyType(formats strfmt.Registry) error { if swag.IsZero(m.BodyType) { // not required return nil } if err := validate.MaxLength("body_type", "body", m.BodyType, 256); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) 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 } func (m *CommonUpdateCarRequest) validateCountry(formats strfmt.Registry) error { if swag.IsZero(m.Country) { // not required return nil } if err := validate.MaxLength("country", "body", m.Country, 256); err != nil { return err } return nil } var commonUpdateCarRequestTypeDltLevelPropEnum []interface{} func init() { var res []int64 if err := json.Unmarshal([]byte(`[0,1,2,3,4,5,6,255]`), &res); err != nil { panic(err) } for _, v := range res { commonUpdateCarRequestTypeDltLevelPropEnum = append(commonUpdateCarRequestTypeDltLevelPropEnum, v) } } // prop value enum func (m *CommonUpdateCarRequest) validateDltLevelEnum(path, location string, value int64) error { if err := validate.EnumCase(path, location, value, commonUpdateCarRequestTypeDltLevelPropEnum, true); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validateDltLevel(formats strfmt.Registry) error { if swag.IsZero(m.DltLevel) { // not required return nil } // value enum if err := m.validateDltLevelEnum("dlt_level", "body", m.DltLevel); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validateIccid(formats strfmt.Registry) error { if swag.IsZero(m.Iccid) { // not required return nil } if err := validate.MaxLength("iccid", "body", m.Iccid, 50); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validateModel(formats strfmt.Registry) error { if err := validate.Required("model", "body", m.Model); err != nil { return err } if err := validate.MaxLength("model", "body", *m.Model, 256); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validatePowertrain(formats strfmt.Registry) error { if swag.IsZero(m.Powertrain) { // not required return nil } if err := validate.MaxLength("powertrain", "body", m.Powertrain, 256); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validateRestraint(formats strfmt.Registry) error { if swag.IsZero(m.Restraint) { // not required return nil } if err := validate.MaxLength("restraint", "body", m.Restraint, 256); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validateTrim(formats strfmt.Registry) error { if err := validate.Required("trim", "body", m.Trim); err != nil { return err } if err := validate.MaxLength("trim", "body", *m.Trim, 256); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validateVin(formats strfmt.Registry) error { if err := validate.Required("vin", "body", m.Vin); err != nil { return err } return nil } func (m *CommonUpdateCarRequest) validateYear(formats strfmt.Registry) error { if err := validate.Required("year", "body", m.Year); err != nil { return err } if err := validate.MinimumInt("year", "body", *m.Year, 1000, false); err != nil { return err } if err := validate.MaximumInt("year", "body", *m.Year, 9999, false); err != nil { return err } return nil } // ContextValidate validate this common update car request based on the context it is used func (m *CommonUpdateCarRequest) 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 *CommonUpdateCarRequest) 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 *CommonUpdateCarRequest) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *CommonUpdateCarRequest) UnmarshalBinary(b []byte) error { var res CommonUpdateCarRequest if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }