Sha256: e8b72c6e9f38baf75e67d2f61e8553642ceb2a64c694db407df73d2ebf76b295

Contents?: true

Size: 720 Bytes

Versions: 20

Compression:

Stored size: 720 Bytes

Contents

# encoding: utf-8

module Nimbu
  module Request
    module Validations
      module Required

        # Validate all keys present in a provided hash against required set,
        # on mismatch raise Nimbu::Error::RequiredParams
        # Note that keys need to be in the same format i.e. symbols or strings,
        # otherwise the comparison will fail.
        #
        def assert_required_keys(required, provided)
          result = required.all? do |key|
            provided.has_deep_key? key
          end
          if !result
            raise Nimbu::Error::RequiredParams.new(provided, required)
          end
          result
        end

      end # Required
    end # Validations
  end # Request
end # Nimbu

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
nimbu-api-0.5.0 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.4.4 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.4.3 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.4.2 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.4.1 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.4.0 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.3.0 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.2.1 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.2 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.2.beta.3 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.2.beta.2 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.2.beta.1 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.2.beta lib/nimbu-api/request/validations/required.rb
nimbu-api-0.1.5 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.1.4 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.1.3 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.1.1 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.1 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.0.2 lib/nimbu-api/request/validations/required.rb
nimbu-api-0.0.1 lib/nimbu-api/request/validations/required.rb