Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / validate_integer.rb
index 995f8db..2ae0293 100644 (file)
@@ -2,7 +2,7 @@ module Puppet::Parser::Functions
 
   newfunction(:validate_integer, :doc => <<-'ENDHEREDOC') do |args|
     Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail.
-    
+
     The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
 
     The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
@@ -49,10 +49,12 @@ module Puppet::Parser::Functions
 
     Plus all of the above, but any combination of values passed as strings ('false' or "false").
     Plus all of the above, but with incorrect combinations of negative integer values.
-    Plus all of the above, but with non-integer crap in arrays or maximum / minimum argument.
+    Plus all of the above, but with non-integer items in arrays or maximum / minimum argument.
 
     ENDHEREDOC
 
+    function_deprecation([:validate_integer, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.'])
+
     # tell the user we need at least one, and optionally up to two other parameters
     raise Puppet::ParseError, "validate_integer(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless args.length > 0 and args.length < 4
 
@@ -109,6 +111,7 @@ module Puppet::Parser::Functions
       # check every element of the array
       input.each_with_index do |arg, pos|
         begin
+          raise TypeError if arg.is_a?(Hash)
           arg = Integer(arg.to_s)
           validator.call(arg)
         rescue TypeError, ArgumentError