]> gitweb.fluxo.info Git - puppet-stdlib.git/commit
changed the validate_slength function to accept a min length
authorMartin Hellmich <mhellmic@gmail.com>
Fri, 28 Jun 2013 16:03:37 +0000 (18:03 +0200)
committerMartin Hellmich <mhellmic@gmail.com>
Tue, 6 Aug 2013 08:05:16 +0000 (10:05 +0200)
commit0206d367c05a7fb2c3bbd7d547e1306541acbef6
tree023947900396ae5ac21cec0e52c570c0a0f93f9d
parentb975bd66aa7345a5eeb54eb79dd0f708934609f8
changed the validate_slength function to accept a min length

An optional third parameter can be given a min length. The function
then only passes successfully, if all strings are in the range
min_length <= string <= max_length

update and fix function and unit tests

the check for the minlength has to be written differently
because 0 values should be possible. We now check
a) if the input is convertible, and throw a ParseError and
b) if the input .is_a?(Numeric) and ask for a positive number
it's not as clean as for maxlength, but keeps a similar behaviour

refined the error checking for the min length

try to convert to Integer(args[2]) and fail,
if it's not possible

changed the tests accordingly to the new parameter checking
lib/puppet/parser/functions/validate_slength.rb
spec/unit/puppet/parser/functions/validate_slength_spec.rb