216 lines
4.5 KiB
Go
216 lines
4.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"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// CommonCarUpdate common car update
|
|
//
|
|
// swagger:model common.CarUpdate
|
|
type CommonCarUpdate struct {
|
|
|
|
// err
|
|
Err int64 `json:"err,omitempty"`
|
|
|
|
// id
|
|
ID int64 `json:"id,omitempty"`
|
|
|
|
// info
|
|
// Max Length: 1000
|
|
Info string `json:"info,omitempty"`
|
|
|
|
// manifest id
|
|
// Required: true
|
|
ManifestID *int64 `json:"manifest_id"`
|
|
|
|
// status
|
|
// Max Length: 100
|
|
Status string `json:"status,omitempty"`
|
|
|
|
// update source
|
|
UpdateSource string `json:"updateSource,omitempty"`
|
|
|
|
// updatemanifest
|
|
Updatemanifest *CommonUpdateManifest `json:"updatemanifest,omitempty"`
|
|
|
|
// username
|
|
// Required: true
|
|
Username *string `json:"username"`
|
|
|
|
// vin
|
|
// Required: true
|
|
// Max Length: 17
|
|
Vin *string `json:"vin"`
|
|
}
|
|
|
|
// Validate validates this common car update
|
|
func (m *CommonCarUpdate) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateInfo(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateManifestID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateStatus(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateUpdatemanifest(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateUsername(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateVin(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCarUpdate) validateInfo(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Info) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.MaxLength("info", "body", m.Info, 1000); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCarUpdate) validateManifestID(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("manifest_id", "body", m.ManifestID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCarUpdate) validateStatus(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Status) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.MaxLength("status", "body", m.Status, 100); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCarUpdate) validateUpdatemanifest(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Updatemanifest) { // not required
|
|
return nil
|
|
}
|
|
|
|
if m.Updatemanifest != nil {
|
|
if err := m.Updatemanifest.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("updatemanifest")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("updatemanifest")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCarUpdate) validateUsername(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("username", "body", m.Username); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCarUpdate) validateVin(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("vin", "body", m.Vin); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.MaxLength("vin", "body", *m.Vin, 17); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this common car update based on the context it is used
|
|
func (m *CommonCarUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateUpdatemanifest(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *CommonCarUpdate) contextValidateUpdatemanifest(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if m.Updatemanifest != nil {
|
|
|
|
if swag.IsZero(m.Updatemanifest) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := m.Updatemanifest.ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("updatemanifest")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("updatemanifest")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *CommonCarUpdate) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *CommonCarUpdate) UnmarshalBinary(b []byte) error {
|
|
var res CommonCarUpdate
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|