Example #1
0
// Validate implements the api.Validator interface
func (m *DeviceIdentifier) Validate() error {
	if err := api.NotEmptyAndValidID(m.AppId, "AppId"); err != nil {
		return err
	}
	if err := api.NotEmptyAndValidID(m.DevId, "DevId"); err != nil {
		return err
	}
	return nil
}
Example #2
0
// Validate implements the api.Validator interface
func (m *Device) Validate() error {
	if err := api.NotEmptyAndValidID(m.AppId, "AppId"); err != nil {
		return err
	}
	if err := api.NotEmptyAndValidID(m.DevId, "DevId"); err != nil {
		return err
	}
	if err := api.NotNilAndValid(m.Device, "Device"); err != nil {
		return err
	}
	return nil
}
Example #3
0
// Validate implements the api.Validator interface
func (m *Device) Validate() error {
	if m.AppEui == nil || m.AppEui.IsEmpty() {
		return errors.NewErrInvalidArgument("AppEui", "can not be empty")
	}
	if m.DevEui == nil || m.DevEui.IsEmpty() {
		return errors.NewErrInvalidArgument("DevEui", "can not be empty")
	}
	if err := api.NotEmptyAndValidID(m.AppId, "AppId"); err != nil {
		return err
	}
	if err := api.NotEmptyAndValidID(m.DevId, "DevId"); err != nil {
		return err
	}
	return nil
}
Example #4
0
// Validate implements the api.Validator interface
func (m *DownlinkMessage) Validate() error {
	if err := api.NotEmptyAndValidID(m.DevId, "DevId"); err != nil {
		return err
	}
	if err := api.NotEmptyAndValidID(m.AppId, "AppId"); err != nil {
		return err
	}

	if err := api.NotNilAndValid(m.DownlinkOption, "DownlinkOption"); err != nil {
		return err
	}
	if m.Message != nil {
		if err := m.Message.Validate(); err != nil {
			return errors.NewErrInvalidArgument("Message", err.Error())
		}
	}
	return nil
}
Example #5
0
// Validate implements the api.Validator interface
func (m *ApplicationHandlerRegistration) Validate() error {
	if err := api.NotEmptyAndValidID(m.AppId, "AppId"); err != nil {
		return err
	}
	if m.HandlerId == "" {
		return errors.NewErrInvalidArgument("HandlerId", "can not be empty")
	}
	return nil
}
Example #6
0
// Validate implements the api.Validator interface
func (m *Announcement) Validate() error {
	if err := api.NotEmptyAndValidID(m.Id, "Id"); err != nil {
		return err
	}
	switch m.ServiceName {
	case "router", "broker", "handler":
	default:
		return errors.NewErrInvalidArgument("ServiceName", "expected one of router, broker, handler but was "+m.ServiceName)
	}
	return nil
}
Example #7
0
// Validate implements the api.Validator interface
func (m *DeduplicatedUplinkMessage) Validate() error {
	if err := api.NotEmptyAndValidID(m.AppId, "AppId"); err != nil {
		return err
	}
	if err := api.NotEmptyAndValidID(m.DevId, "DevId"); err != nil {
		return err
	}
	if err := api.NotNilAndValid(m.ProtocolMetadata, "ProtocolMetadata"); err != nil {
		return err
	}
	if m.ResponseTemplate != nil {
		if err := m.ResponseTemplate.Validate(); err != nil {
			return errors.NewErrInvalidArgument("ResponseTemplate", err.Error())
		}
	}
	if m.Message != nil {
		if err := m.Message.Validate(); err != nil {
			return errors.NewErrInvalidArgument("Message", err.Error())
		}
	}
	return nil
}
Example #8
0
// Validate implements the api.Validator interface
func (m *Application) Validate() error {
	if err := api.NotEmptyAndValidID(m.AppId, "AppId"); err != nil {
		return err
	}
	return nil
}