Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / validate_numeric.rb
index d2e4d16..4205b30 100644 (file)
@@ -2,7 +2,7 @@ module Puppet::Parser::Functions
 
   newfunction(:validate_numeric, :doc => <<-'ENDHEREDOC') do |args|
     Validate that the first argument is a numeric value (or an array of numeric values). 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.
@@ -15,6 +15,8 @@ module Puppet::Parser::Functions
 
     ENDHEREDOC
 
+    function_deprecation([:validate_numeric, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. 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_numeric(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless args.length > 0 and args.length < 4
 
@@ -71,6 +73,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 = Float(arg.to_s)
           validator.call(arg)
         rescue TypeError, ArgumentError