Module: Github::Validations::Required

Included in:
Github::Validations
Defined in:
lib/github_api/validations/required.rb

Instance Method Summary collapse

Instance Method Details

#assert_required_keys(*required, provided) ⇒ Object

Validate all keys present in a provided hash against required set, on mismatch raise Github::Error::RequiredParams Note that keys need to be in the same format i.e. symbols or strings, otherwise the comparison will fail.


12
13
14
15
16
# File 'lib/github_api/validations/required.rb', line 12

def assert_required_keys(*required, provided)
  required.flatten.all? { |key|
    provided.deep_key?(key.to_s)
  } || (raise Github::Error::RequiredParams.new(provided, required))
end