416 lines
8.5 KiB
Go
416 lines
8.5 KiB
Go
// 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"
|
|
"strconv"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// CommonCar common car
|
|
//
|
|
// swagger:model common.Car
|
|
type CommonCar struct {
|
|
|
|
// body type
|
|
// Max Length: 256
|
|
BodyType string `json:"body_type,omitempty"`
|
|
|
|
// country
|
|
// Max Length: 256
|
|
Country string `json:"country,omitempty"`
|
|
|
|
// document
|
|
Document string `json:"document,omitempty"`
|
|
|
|
// drivers
|
|
Drivers []*CommonCarToDriver `json:"drivers"`
|
|
|
|
// ecu list
|
|
EcuList string `json:"ecu_list,omitempty"`
|
|
|
|
// flashpack
|
|
Flashpack string `json:"flashpack,omitempty"`
|
|
|
|
// iccid
|
|
// Max Length: 50
|
|
Iccid string `json:"iccid,omitempty"`
|
|
|
|
// manifests
|
|
Manifests []*CommonStatusManifest `json:"manifests"`
|
|
|
|
// model
|
|
// Required: true
|
|
// Max Length: 256
|
|
Model *string `json:"model"`
|
|
|
|
// os version
|
|
OsVersion string `json:"os_version,omitempty"`
|
|
|
|
// powertrain
|
|
// Max Length: 256
|
|
Powertrain string `json:"powertrain,omitempty"`
|
|
|
|
// region
|
|
Region string `json:"region,omitempty"`
|
|
|
|
// restraint
|
|
// Max Length: 256
|
|
Restraint string `json:"restraint,omitempty"`
|
|
|
|
// sold status
|
|
SoldStatus string `json:"sold_status,omitempty"`
|
|
|
|
// sums version
|
|
SumsVersion string `json:"sums_version,omitempty"`
|
|
|
|
// tags
|
|
// Max Items: 50
|
|
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 car
|
|
func (m *CommonCar) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateBodyType(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateCountry(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateDrivers(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateIccid(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateManifests(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.validateTags(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 *CommonCar) 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 *CommonCar) 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
|
|
}
|
|
|
|
func (m *CommonCar) validateDrivers(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Drivers) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Drivers); i++ {
|
|
if swag.IsZero(m.Drivers[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Drivers[i] != nil {
|
|
if err := m.Drivers[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("drivers" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("drivers" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCar) 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 *CommonCar) validateManifests(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Manifests) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Manifests); i++ {
|
|
if swag.IsZero(m.Manifests[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Manifests[i] != nil {
|
|
if err := m.Manifests[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("manifests" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("manifests" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCar) 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 *CommonCar) 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 *CommonCar) 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 *CommonCar) validateTags(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Tags) { // not required
|
|
return nil
|
|
}
|
|
|
|
iTagsSize := int64(len(m.Tags))
|
|
|
|
if err := validate.MaxItems("tags", "body", iTagsSize, 50); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCar) 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 *CommonCar) validateVin(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("vin", "body", m.Vin); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCar) 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 car based on the context it is used
|
|
func (m *CommonCar) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateDrivers(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateManifests(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCar) contextValidateDrivers(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Drivers); i++ {
|
|
|
|
if m.Drivers[i] != nil {
|
|
|
|
if swag.IsZero(m.Drivers[i]) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := m.Drivers[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("drivers" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("drivers" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCar) contextValidateManifests(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Manifests); i++ {
|
|
|
|
if m.Manifests[i] != nil {
|
|
|
|
if swag.IsZero(m.Manifests[i]) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := m.Manifests[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("manifests" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("manifests" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *CommonCar) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *CommonCar) UnmarshalBinary(b []byte) error {
|
|
var res CommonCar
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|