// 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" ) // CommonIssue common issue // // swagger:model common.Issue type CommonIssue struct { // description // Required: true // Max Length: 1024 Description *string `json:"description"` // driver id DriverID string `json:"driver_id,omitempty"` // id ID int64 `json:"id,omitempty"` // images Images []*CommonIssueImage `json:"images"` // timestamp // Required: true Timestamp *string `json:"timestamp"` // title // Required: true // Max Length: 256 Title *string `json:"title"` // vin // Required: true Vin *string `json:"vin"` } // Validate validates this common issue func (m *CommonIssue) Validate(formats strfmt.Registry) error { var res []error if err := m.validateDescription(formats); err != nil { res = append(res, err) } if err := m.validateImages(formats); err != nil { res = append(res, err) } if err := m.validateTimestamp(formats); err != nil { res = append(res, err) } if err := m.validateTitle(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 *CommonIssue) validateDescription(formats strfmt.Registry) error { if err := validate.Required("description", "body", m.Description); err != nil { return err } if err := validate.MaxLength("description", "body", *m.Description, 1024); err != nil { return err } return nil } func (m *CommonIssue) validateImages(formats strfmt.Registry) error { if swag.IsZero(m.Images) { // not required return nil } for i := 0; i < len(m.Images); i++ { if swag.IsZero(m.Images[i]) { // not required continue } if m.Images[i] != nil { if err := m.Images[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("images" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("images" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *CommonIssue) validateTimestamp(formats strfmt.Registry) error { if err := validate.Required("timestamp", "body", m.Timestamp); err != nil { return err } return nil } func (m *CommonIssue) validateTitle(formats strfmt.Registry) error { if err := validate.Required("title", "body", m.Title); err != nil { return err } if err := validate.MaxLength("title", "body", *m.Title, 256); err != nil { return err } return nil } func (m *CommonIssue) validateVin(formats strfmt.Registry) error { if err := validate.Required("vin", "body", m.Vin); err != nil { return err } return nil } // ContextValidate validate this common issue based on the context it is used func (m *CommonIssue) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateImages(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CommonIssue) contextValidateImages(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Images); i++ { if m.Images[i] != nil { if swag.IsZero(m.Images[i]) { // not required return nil } if err := m.Images[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("images" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("images" + "." + strconv.Itoa(i)) } return err } } } return nil } // MarshalBinary interface implementation func (m *CommonIssue) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *CommonIssue) UnmarshalBinary(b []byte) error { var res CommonIssue if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }