1 module Puppet::Parser::Functions
3 newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args|
4 Validate that all passed values are either true or false. Abort catalog
5 compilation if any value fails this check.
7 The following values will pass:
11 validate_bool(true, true, false, $iamtrue)
13 The following values will fail, causing compilation to abort:
15 $some_array = [ true ]
16 validate_bool("false")
18 validate_bool($some_array)
22 unless args.length > 0 then
23 raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)")
27 unless (arg.is_a?(TrueClass) || arg.is_a?(FalseClass))
28 raise Puppet::ParseError, ("#{arg.inspect} is not a boolean. It looks to be a #{arg.class}")