[Moose-commits] r7895 - in MooseX-Types-Structured/trunk: .
lib/MooseX/Meta/TypeConstraint lib/MooseX/Types t
jnapiorkowski at code2.0beta.co.uk
jnapiorkowski at code2.0beta.co.uk
Mon Apr 6 18:11:30 GMT 2009
Author: jnapiorkowski
Date: 2009-04-06 11:11:30 -0700 (Mon, 06 Apr 2009)
New Revision: 7895
Modified:
MooseX-Types-Structured/trunk/Changes
MooseX-Types-Structured/trunk/lib/MooseX/Meta/TypeConstraint/Structured.pm
MooseX-Types-Structured/trunk/lib/MooseX/Types/Structured.pm
MooseX-Types-Structured/trunk/t/12-error.t
Log:
fixed incorrect alway finding an error with TC->validate
Modified: MooseX-Types-Structured/trunk/Changes
===================================================================
--- MooseX-Types-Structured/trunk/Changes 2009-04-06 14:24:12 UTC (rev 7894)
+++ MooseX-Types-Structured/trunk/Changes 2009-04-06 18:11:30 UTC (rev 7895)
@@ -1,5 +1,8 @@
Revision history for MooseX-Types-Structured
+0.11 06 April 2009
+ - Fixed braindead bug in the way I override ->validate, which caused
+ valiate to never correctly pass a constraint.
0.10 02 April 2009
- Minor documentation grammar fixes and one major example error fixed
- Much improved error reporting. Now we return the 'internal' error
Modified: MooseX-Types-Structured/trunk/lib/MooseX/Meta/TypeConstraint/Structured.pm
===================================================================
--- MooseX-Types-Structured/trunk/lib/MooseX/Meta/TypeConstraint/Structured.pm 2009-04-06 14:24:12 UTC (rev 7894)
+++ MooseX-Types-Structured/trunk/lib/MooseX/Meta/TypeConstraint/Structured.pm 2009-04-06 18:11:30 UTC (rev 7895)
@@ -78,13 +78,13 @@
override 'validate' => sub {
my ($self, @args) = @_;
- my $compiled_type_constraint = $self->_compiled_type_constraint;
my $message = bless {message=>undef}, 'MooseX::Types::Structured::Message';
- my $result = $compiled_type_constraint->(@args, $message);
- if($result) {
- return $result;
+ if ($self->_compiled_type_constraint->(@args, $message)) {
+ ## Everything is good, no error message to return
+ return undef;
} else {
+ ## Whoops, need to figure out the right error message
my $args = Devel::PartialDump::dump(@args);
if(my $message = $message->{message}) {
return $self->get_message("$args, Internal Validation Error is: $message");
Modified: MooseX-Types-Structured/trunk/lib/MooseX/Types/Structured.pm
===================================================================
--- MooseX-Types-Structured/trunk/lib/MooseX/Types/Structured.pm 2009-04-06 14:24:12 UTC (rev 7894)
+++ MooseX-Types-Structured/trunk/lib/MooseX/Types/Structured.pm 2009-04-06 18:11:30 UTC (rev 7895)
@@ -8,7 +8,7 @@
use Sub::Exporter -setup => { exports => [ qw(Dict Tuple Optional slurpy) ] };
use Devel::PartialDump;
-our $VERSION = '0.10';
+our $VERSION = '0.11';
our $AUTHORITY = 'cpan:JJNAPIORK';
=head1 NAME
Modified: MooseX-Types-Structured/trunk/t/12-error.t
===================================================================
--- MooseX-Types-Structured/trunk/t/12-error.t 2009-04-06 14:24:12 UTC (rev 7894)
+++ MooseX-Types-Structured/trunk/t/12-error.t 2009-04-06 18:11:30 UTC (rev 7895)
@@ -1,7 +1,7 @@
BEGIN {
use strict;
use warnings;
- use Test::More tests=>24;
+ use Test::More tests=>25;
}
use Moose::Util::TypeConstraints;
@@ -119,3 +119,7 @@
like $deep_tuple->validate([1,{a=>2},{name=>'Vincent',age=>'Hello'}]),
qr/Error is: Validation failed for 'MooseX::Types::Structured::Dict\[name,Str,age,Int\]'/,
'Example deeper error';
+
+## Success Tests...
+
+ok !$deep_tuple->validate([1,{a=>2},{name=>'John',age=>40}]), 'Validates ok';
More information about the Moose-commits
mailing list