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