First, thanks for your work on this module.
Example:
my $rdv = leaf(constraints => [required]);
$rdv->process(0);
should pass, but it fails the required test.
The documentation is a bit imprecise. In POD of Data::TreeValidator::Constraints, "required" is
described as "defined, and stringifies to a true value (not the empty string)". That's confusing
because, despite the suggestive parentheses, "stringifies to a true value" is not the same
thing as "not the empty string": 0 is not the empty string, but also does not stringify to a true
value. On the other hand, look at the code for required:
fail_constraint("Required") unless defined $_ && "$_" ne '';
It is clear that "not the empty string" is the desired test, and stringifies to a true value is not
what is actually tested. So 0 should pass required.
I believe the bug is line 46 of Data::TreeValidator::Leaf
my $process = $input || $args{initialize};
Here $input of 0 gets converted to undef, and later on appears to be missing. It should of
course be
my $process = defined $input ? $input : $args{initialize};