diff options
author | Adrien Thebo <git@somethingsinistral.net> | 2013-08-12 12:52:17 -0700 |
---|---|---|
committer | Adrien Thebo <git@somethingsinistral.net> | 2013-08-12 12:56:00 -0700 |
commit | 24911db44ca086b00ce543f7da08e5176f7c93a8 (patch) | |
tree | 438e8e7d493ec60573d47fc75ccf4ba0d90bc8ef /lib/puppet/parser | |
parent | 200e585ea78a5f3587ca35bb0fe453c0670ed65c (diff) | |
download | puppet-stdlib-24911db44ca086b00ce543f7da08e5176f7c93a8.tar.gz puppet-stdlib-24911db44ca086b00ce543f7da08e5176f7c93a8.tar.bz2 |
(maint) Validate input argument in a single location
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/functions/validate_slength.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/puppet/parser/functions/validate_slength.rb b/lib/puppet/parser/functions/validate_slength.rb index 34dfcf2..7d534f3 100644 --- a/lib/puppet/parser/functions/validate_slength.rb +++ b/lib/puppet/parser/functions/validate_slength.rb @@ -25,10 +25,6 @@ module Puppet::Parser::Functions input, max_length, min_length = *args - unless (input.is_a?(String) or input.is_a?(Array)) - raise Puppet::ParseError, "validate_slength(): Expected first argument to be a String or Array, got a #{input.class}" - end - begin max_length = Integer(max_length) raise ArgumentError if max_length <= 0 @@ -62,12 +58,14 @@ module Puppet::Parser::Functions validator.call(input) when Array input.each_with_index do |arg, pos| - if arg.is_a?(String) + if arg.is_a? String validator.call(arg) else - raise Puppet::ParseError, "validate_slength(): Expected element at array position #{pos} to be a String, got a #{arg.class}" + raise Puppet::ParseError, "validate_slength(): Expected element at array position #{pos} to be a String, got #{arg.class}" end end + else + raise Puppet::ParseError, "validate_slength(): Expected first argument to be a String or Array, got #{input.class}" end end end |