Subject: | Required and supplied parameter rejected if value is 0 |
Hi
Code and output:
#!/usr/bin/perl
use common::sense;
use Brannigan;
# ------------
my($validator) = Brannigan -> new
({
name => 'content',
params =>
{
action =>
{
required => 1,
value_between => [0, 3],
},
},
});
my($data) =
{
action => 0,
};
for (sort keys %$data)
{
print "Data: $_ => $$data{$_}. length(", length($$data{$_}), "). \n";
}
print "\n";
my($result) = $validator -> process('content', $data);
for (keys %$result)
{
print "Result: $_ => $$result{$_}. \n";
}
print "\n";
for (keys %{$$result{_rejects} })
{
print "Reject: $_ => ", join(', ', @{$$result{_rejects}{$_} }), ". \n";
}
ron@zephyr:~$ ./x.pl
Data: action => 0. length(1).
Result: _rejects => HASH(0x81d54c0).
Result: action => 0.
Reject: action => required(1).
I tried tracing thru the code, but gave up :-(.