13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/gooddata/lcm/helpers/check_helper.rb', line 13
def check_params(specification, params)
specification.keys.each do |param_name|
value = params.send(param_name)
type = specification[param_name][:type]
if value.nil?
if specification[param_name][:opts][:required]
fail("Mandatory parameter '#{param_name}' of type '#{type}' is not specified")
end
else
if type.class.const_get(:CATEGORY) == :complex && !value.is_a?(Hash)
puts JSON.pretty_generate(params)
fail "Expected parameter '#{param_name}' to be kind of '#{type}', got '#{value.class.name}'"
end
unless type.check(value)
fail "Parameter '#{param_name}' has invalid type, expected: #{type}"
end
end
end
end
|