Sha256: 9389ecfd46685b9021f7c69ddd0cb31782e1ccd162e826e488b846fd6f76f8bc

Contents?: true

Size: 1.29 KB

Versions: 21

Compression:

Stored size: 1.29 KB

Contents

# Toplevel Pubnub module.
module Pubnub
  # Validator module that holds all validators modules
  module Validator
    # Validator for AddChannelsToPush event
    module AddChannelsToPush
      include CommonValidator

      def validate!
        return if @skip_validate
        validate_push_token!
        validate_push_gateway!
        validate_channel!
        validate_topic! if @push_gateway.eql? 'apns2'
      end

      private

      def validate_push_token!
        return unless @push_token.nil? || @push_token.empty?
        raise(
          ArgumentError.new,
          ':push_token is required for AddChannelsToPush event.'
        )
      end

      def validate_push_gateway!
        return unless @push_gateway.nil? || @push_gateway.empty?
        raise(
          ArgumentError.new,
          ':push_gateway is required for AddChannelsToPush event.'
        )
      end

      def validate_channel!
        return unless @channel.nil? || @channel.empty?
        raise(
          ArgumentError.new,
          ':channel is required for AddChannelsToPush event.'
        )
      end

      def validate_topic!
        return unless @topic.nil? || @topic.empty?
        raise(
          ArgumentError.new,
          ':topic is required for AddChannelsToPush event.'
        )
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pubnub-5.4.0 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.3.5 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.3.4 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.3.3 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.3.2 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.3.1 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.3.0 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.2.2 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.2.1 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.2.0 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.1.2 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.1.1 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.1.0 lib/pubnub/validators/add_channels_to_push.rb
pubnub-5.0.0 lib/pubnub/validators/add_channels_to_push.rb
pubnub-4.8.0 lib/pubnub/validators/add_channels_to_push.rb
pubnub-4.7.1 lib/pubnub/validators/add_channels_to_push.rb
pubnub-4.7.0 lib/pubnub/validators/add_channels_to_push.rb
pubnub-4.6.2 lib/pubnub/validators/add_channels_to_push.rb
pubnub-4.6.1 lib/pubnub/validators/add_channels_to_push.rb
pubnub-4.6.0 lib/pubnub/validators/add_channels_to_push.rb