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

// CommonSubscriptionConfiguration common subscription configuration
//
// swagger:model common.SubscriptionConfiguration
type CommonSubscriptionConfiguration struct {

	// configuration
	// Example: 9a1a6949d7f8a511df6e2e2771e444dbd6de97e7d98bdecbb5adc4b8965ce3bef353f523dbea123d7882dc043d415cda02810bad1b6f1b8c6202234a424b7d5b
	// Required: true
	Configuration *string `json:"configuration"`

	// did
	// Example: 7d5b
	// Required: true
	Did *string `json:"did"`

	// ecu
	// Required: true
	// Max Length: 100
	Ecu *string `json:"ecu"`

	// feature id
	// Required: true
	FeatureID *string `json:"feature_id"`

	// hw version
	// Required: true
	// Max Length: 100
	HwVersion *string `json:"hw_version"`

	// mask
	// Example: 7d5b
	// Required: true
	Mask *string `json:"mask"`

	// pid
	// Example: 7d5b
	// Required: true
	Pid *string `json:"pid"`

	// sw version
	// Required: true
	// Max Length: 100
	SwVersion *string `json:"sw_version"`
}

// Validate validates this common subscription configuration
func (m *CommonSubscriptionConfiguration) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

func (m *CommonSubscriptionConfiguration) validateConfiguration(formats strfmt.Registry) error {

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

	return nil
}

func (m *CommonSubscriptionConfiguration) validateDid(formats strfmt.Registry) error {

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

	return nil
}

func (m *CommonSubscriptionConfiguration) validateEcu(formats strfmt.Registry) error {

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

	if err := validate.MaxLength("ecu", "body", *m.Ecu, 100); err != nil {
		return err
	}

	return nil
}

func (m *CommonSubscriptionConfiguration) validateFeatureID(formats strfmt.Registry) error {

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

	return nil
}

func (m *CommonSubscriptionConfiguration) validateHwVersion(formats strfmt.Registry) error {

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

	if err := validate.MaxLength("hw_version", "body", *m.HwVersion, 100); err != nil {
		return err
	}

	return nil
}

func (m *CommonSubscriptionConfiguration) validateMask(formats strfmt.Registry) error {

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

	return nil
}

func (m *CommonSubscriptionConfiguration) validatePid(formats strfmt.Registry) error {

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

	return nil
}

func (m *CommonSubscriptionConfiguration) validateSwVersion(formats strfmt.Registry) error {

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

	if err := validate.MaxLength("sw_version", "body", *m.SwVersion, 100); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this common subscription configuration based on context it is used
func (m *CommonSubscriptionConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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