X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fvalidate_numeric.rb;h=4205b30d81594d84b308bf636fdf8bea0846f263;hb=6963202b4b62c2816655ac9532521b018fdf83bd;hp=d2e4d16a08faa9a0bdf79373631bb8d879dada83;hpb=a69999e580f8b3abd12446c2d6ad59e517651813;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb index d2e4d16a0..4205b30d8 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb @@ -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