1 module Puppet::Parser::Functions
3 newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args|
4 Validate that all passed values are hash data structures. Abort catalog
5 compilation if any value fails this check.
7 The following values will pass:
9 $my_hash = { 'one' => 'two' }
10 validate_hash($my_hash)
12 The following values will fail, causing compilation to abort:
15 validate_hash('some_string')
17 validate_hash($undefined)
21 function_deprecation([:validate_hash, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.'])
23 unless args.length > 0 then
24 raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)")
28 unless arg.is_a?(Hash)
29 raise Puppet::ParseError, ("#{arg.inspect} is not a Hash. It looks to be a #{arg.class}")