Sha256: 61de59f6ee5690d988cbcf21175fdf47e16f10bbbf96f6c8fd636a1aa006c53e

Contents?: true

Size: 778 Bytes

Versions: 6

Compression:

Stored size: 778 Bytes

Contents

# encoding: utf-8

require_relative '../error/client_error'

module Github
  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 Github::Error::UnknownValue.new(k,v, permitted[k].join(', '))

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

    end # Format
  end # Validations
end # Github

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
github_api2-1.0.1 lib/github_api2/validations/format.rb
github_api2-1.0.0 lib/github_api2/validations/format.rb
github_api-0.19.0 lib/github_api/validations/format.rb
lingfennan-github_api-0.18.2 lib/github_api/validations/format.rb
github_api-0.18.2 lib/github_api/validations/format.rb
github_api-0.18.1 lib/github_api/validations/format.rb