Sha256: 73a145a4fe2f39be697ea22d698d04c7bfe71dfa80a406c0d0dca26fd5b72df0

Contents?: true

Size: 748 Bytes

Versions: 21

Compression:

Stored size: 748 Bytes

Contents

# encoding: utf-8

module BitBucket
  module Validations
    module Format

      # Ensures that value for a given key is of the correct form whether
      # matching regular expression or set of predefined values.
      #
      def assert_valid_values(permitted, params)
        params.each do |k, v|
          next unless permitted.keys.include?(k)
          if permitted[k].is_a?(Array) && !permitted[k].include?(params[k])
            raise BitBucket::Error::UnknownValue.new(k,v, permitted[k].join(', '))

          elsif permitted[k].is_a?(Regexp) && !(permitted[k] =~ params[k])
            raise BitBucket::Error::UnknownValue.new(k,v, permitted[k])
          end
        end
      end

    end # Format
  end # Validations
end # BitBucket

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
codenamev_bitbucket_api-0.4.1 lib/bitbucket_rest_api/validations/format.rb
codenamev_bitbucket_api-0.4.0 lib/bitbucket_rest_api/validations/format.rb
zz_bitbucket_rest_api-0.1.11 lib/bitbucket_rest_api/validations/format.rb
zz_bitbucket_rest_api-0.1.10 lib/bitbucket_rest_api/validations/format.rb
zz_bitbucket_rest_api-0.1.9 lib/bitbucket_rest_api/validations/format.rb
zz_bitbucket_rest_api-0.1.8 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api2-0.9.5 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api2-0.9.1 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api2-0.2.2 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api2-0.2.1 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api2-0.2.0 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api-0.1.7 lib/bitbucket_rest_api/validations/format.rb
reenhanced_bitbucket_api-0.3.2 lib/bitbucket_rest_api/validations/format.rb
reenhanced_bitbucket_api-0.3.1 lib/bitbucket_rest_api/validations/format.rb
reenhanced_bitbucket_api-0.3.0 lib/bitbucket_rest_api/validations/format.rb
reenhanced_bitbucket_api-0.1.6 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api-0.1.5 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api-0.1.4 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api-0.1.2 lib/bitbucket_rest_api/validations/format.rb
bitbucket_rest_api-0.1.1 lib/bitbucket_rest_api/validations/format.rb