// 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" ) // CommonCANBus common c a n bus // // swagger:model common.CANBus type CommonCANBus struct { // data logger enabled DataLoggerEnabled bool `json:"data_logger_enabled,omitempty"` // dtc enabled DtcEnabled bool `json:"dtc_enabled,omitempty"` // enabled Enabled bool `json:"enabled,omitempty"` // filters Filters []*CommonCANFilter `json:"filters"` // max disk buffer size // Maximum: 1.7179869184e+10 // Minimum: 0 MaxDiskBufferSize *int64 `json:"max_disk_buffer_size,omitempty"` // max mem buffer size // Maximum: 1.073741824e+09 // Minimum: 0 MaxMemBufferSize *int64 `json:"max_mem_buffer_size,omitempty"` } // Validate validates this common c a n bus func (m *CommonCANBus) Validate(formats strfmt.Registry) error { var res []error if err := m.validateFilters(formats); err != nil { res = append(res, err) } if err := m.validateMaxDiskBufferSize(formats); err != nil { res = append(res, err) } if err := m.validateMaxMemBufferSize(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CommonCANBus) validateFilters(formats strfmt.Registry) error { if swag.IsZero(m.Filters) { // not required return nil } for i := 0; i < len(m.Filters); i++ { if swag.IsZero(m.Filters[i]) { // not required continue } if m.Filters[i] != nil { if err := m.Filters[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("filters" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("filters" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *CommonCANBus) validateMaxDiskBufferSize(formats strfmt.Registry) error { if swag.IsZero(m.MaxDiskBufferSize) { // not required return nil } if err := validate.MinimumInt("max_disk_buffer_size", "body", *m.MaxDiskBufferSize, 0, false); err != nil { return err } if err := validate.MaximumInt("max_disk_buffer_size", "body", *m.MaxDiskBufferSize, 1.7179869184e+10, false); err != nil { return err } return nil } func (m *CommonCANBus) validateMaxMemBufferSize(formats strfmt.Registry) error { if swag.IsZero(m.MaxMemBufferSize) { // not required return nil } if err := validate.MinimumInt("max_mem_buffer_size", "body", *m.MaxMemBufferSize, 0, false); err != nil { return err } if err := validate.MaximumInt("max_mem_buffer_size", "body", *m.MaxMemBufferSize, 1.073741824e+09, false); err != nil { return err } return nil } // ContextValidate validate this common c a n bus based on the context it is used func (m *CommonCANBus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateFilters(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CommonCANBus) contextValidateFilters(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Filters); i++ { if m.Filters[i] != nil { if swag.IsZero(m.Filters[i]) { // not required return nil } if err := m.Filters[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("filters" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("filters" + "." + strconv.Itoa(i)) } return err } } } return nil } // MarshalBinary interface implementation func (m *CommonCANBus) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *CommonCANBus) UnmarshalBinary(b []byte) error { var res CommonCANBus if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }