Skip Menu |

This queue is for tickets about the Config-Validate CPAN distribution.

Report information
The Basics
Id: 41039
Status: new
Priority: 0/
Queue: Config-Validate

People
Owner: Nobody in particular
Requestors: andri [...] dot.ee
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.2.6
Fixed in: (no value)



Subject: Boolean values not converted
Boolean values are checked, but not are converted to 0/1 in the returned hash. The attached patch fixes this.
Subject: bool-conv.patch
--- Validate.pm~ 2008-02-18 06:18:54.000000000 +0200 +++ Validate.pm 2008-11-18 22:10:59.000000000 +0200 @@ -56,7 +56,7 @@ integer => { validate => \&_validate_integer }, float => { validate => \&_validate_float }, string => { validate => \&_validate_string }, - boolean => { validate => \&_validate_boolean }, + boolean => { validate => \&_validate_boolean, byreference => 1 }, hash => { validate => \&_validate_hash }, array => { validate => \&_validate_array, byreference => 1, @@ -481,17 +481,17 @@ } sub _validate_boolean { - my ($self, $value, $def, $path) = @_; + my ($self, $value_ref, $def, $path) = @_; my @true = qw(y yes t true on); my @false = qw(n no f false off); - $value =~ s/\s+//xg; - $value = 1 if any { lc($value) eq $_ } @true; - $value = 0 if any { lc($value) eq $_ } @false; + $$value_ref =~ s/\s+//xg; + $$value_ref = 1 if any { lc($$value_ref) eq $_ } @true; + $$value_ref = 0 if any { lc($$value_ref) eq $_ } @false; - if ($value !~ /^ [01] $/x) { + if ($$value_ref !~ /^ [01] $/x) { _throw sprintf("%s: invalid value '%s', must be: %s", mkpath($path), - $value, join(', ', (0, 1, @true, @false))); + $$value_ref, join(', ', (0, 1, @true, @false))); } return;