1 module Puppet::Parser::Functions
3 newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args|
4 Validate that all passed values are array data structures. Abort catalog
5 compilation if any value fails this check.
7 The following values will pass:
9 $my_array = [ 'one', 'two' ]
10 validate_array($my_array)
12 The following values will fail, causing compilation to abort:
15 validate_array('some_string')
17 validate_array($undefined)
21 unless args.length > 0 then
22 raise Puppet::ParseError, ("validate_array(): wrong number of arguments (#{args.length}; must be > 0)")
26 unless arg.is_a?(Array)
27 raise Puppet::ParseError, ("#{arg.inspect} is not an Array. It looks to be a #{arg.class}")