Sha256: 9c9d01f89e6e670bc190fc291b52ca55e4057027792e0cd455dfb1f4354c2291

Contents?: true

Size: 1.5 KB

Versions: 21

Compression:

Stored size: 1.5 KB

Contents

# Toplevel Pubnub module.
# frozen_string_literal: true

module Pubnub
  # Validator module that holds all validators modules
  module Validator
    # Validator for RemoveChannelMembers event
    module RemoveChannelMembers
      include CommonValidator

      def validate!
        return if @skip_validate

        validate_subscribe_key!
        validate_channel!
        validate_members!
      end

      private

      def validate_subscribe_key!
        return unless @subscribe_key.nil?

        raise(
          ArgumentError.new(object: self, message: ':subscribe_key is required for remove channel members event.'),
          ':subscribe_key is required for remove channel members event.'
        )
      end

      def validate_channel!
        return unless @channel.nil? || @channel.empty?

        raise(
          ArgumentError.new(object: self, message: ':channel is required for remove channel members event.'),
          ':channel is required for remove channel members event.'
        )
      end

      def validate_members!
        raise(
          ArgumentError.new(object: self, message: ':uuids is required for remove channel members event.'),
          ':uuids is required for remove channel members event.'
        ) if @uuids.nil? || @uuids.empty?

        raise(
          ArgumentError.new(object: self, message: ':uuids parameter for remove channel members must be Array.'),
          ':uuids parameter for remove channel members must be Array.'
        ) if @uuids.class != Array
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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