Skip Menu |

This queue is for tickets about the Data-TreeValidator CPAN distribution.

Report information
The Basics
Id: 78102
Status: resolved
Priority: 0/
Queue: Data-TreeValidator

Owner: Nobody in particular
Requestors: FRIEDMAN [...]

Bug Information
Severity: Important
Broken in: 0.03
Fixed in: (no value)

Subject: options Constraint doesn't work
use Data::TreeValidator::Constraints 'options'; use Data::TreeValidator::Sugar qw/leaf branch/; my $validator = branch {foo => leaf(constraints => [options("A","B")])}; # Should be invalid, since "C" is not in set("A", "B"); my $object = {foo => "C"}; my $process = $validator->process($object); # prints 1 print $process->valid, "\n"; I believe the problem is that in the options() function in Data::TreeValidator::Constraints fail_constraint is never called. In version 0.03 we have the follow excerpt: sub options { my $valid = set(@_); return sub { my ($input) = @_; $valid->contains($input); }; } The line $valid->contains($input); should be $valid->contains($input) or fail_constraint("Input must be in set (@$valid)"); That patch fixes the function. Based on looking at the source code, the type() Constaint also appears to be broken in the same way. $type->check(@_) should be changed to $type->check(@_) or fail_constraint("Input must be a " . $type->name) However, I haven't tested this example.
This has been resolved in 0.04

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to