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 # The deprecation function was being called twice, as validate_bool calls is_bool. I have removed it from here so it only calls deprecation once within is_bool.
23 # function_deprecation([:validate_bool, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.'])
25 unless args.length > 0 then
26 raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)")
30 unless function_is_bool([arg])
31 raise Puppet::ParseError, ("#{arg.inspect} is not a boolean. It looks to be a #{arg.class}")