// 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"
)

// CommonCANFilter common c a n filter
//
// swagger:model common.CANFilter
type CommonCANFilter struct {

	// can id
	// Required: true
	CanID *string `json:"can_id"`

	// edge mask
	// Max Items: 10000
	EdgeMask []int64 `json:"edge_mask"`

	// interval
	// Minimum: 0
	Interval *int64 `json:"interval,omitempty"`
}

// Validate validates this common c a n filter
func (m *CommonCANFilter) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateCanID(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateEdgeMask(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateInterval(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *CommonCANFilter) validateCanID(formats strfmt.Registry) error {

	if err := validate.Required("can_id", "body", m.CanID); err != nil {
		return err
	}

	return nil
}

func (m *CommonCANFilter) validateEdgeMask(formats strfmt.Registry) error {
	if swag.IsZero(m.EdgeMask) { // not required
		return nil
	}

	iEdgeMaskSize := int64(len(m.EdgeMask))

	if err := validate.MaxItems("edge_mask", "body", iEdgeMaskSize, 10000); err != nil {
		return err
	}

	return nil
}

func (m *CommonCANFilter) validateInterval(formats strfmt.Registry) error {
	if swag.IsZero(m.Interval) { // not required
		return nil
	}

	if err := validate.MinimumInt("interval", "body", *m.Interval, 0, false); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this common c a n filter based on context it is used
func (m *CommonCANFilter) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (m *CommonCANFilter) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *CommonCANFilter) UnmarshalBinary(b []byte) error {
	var res CommonCANFilter
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
