Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / validate_bool.rb
1 #
2 # validate_bool.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:validate_bool, :doc => <<-'DOC') do |args|
6     Validate that all passed values are either true or false. Abort catalog
7     compilation if any value fails this check.
8
9     The following values will pass:
10
11         $iamtrue = true
12         validate_bool(true)
13         validate_bool(true, true, false, $iamtrue)
14
15     The following values will fail, causing compilation to abort:
16
17         $some_array = [ true ]
18         validate_bool("false")
19         validate_bool("true")
20         validate_bool($some_array)
21
22     DOC
23
24     if args.empty?
25       raise Puppet::ParseError, "validate_bool(): wrong number of arguments (#{args.length}; must be > 0)"
26     end
27
28     args.each do |arg|
29       unless function_is_bool([arg])
30         raise Puppet::ParseError, "#{arg.inspect} is not a boolean.  It looks to be a #{arg.class}"
31       end
32     end
33   end
34 end