X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FAttribute.pm;h=73e8f9ec4de2924e491a85d21145de4794868ea2;hb=f55f60dd1546028de576a08ef877af282e902756;hp=66110e672417ca4cfdc249dc9fc8c61b2691a2fe;hpb=ca5a9ec19e7fb9765124fa5a27bd22a48dc171d4;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 66110e6..73e8f9e 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -225,20 +225,19 @@ sub validate_args { } sub verify_against_type_constraint { - return 1 unless $_[0]->{type_constraint}; + my ($self, $value) = @_; + my $tc = $self->type_constraint; + return 1 unless $tc; - local $_ = $_[1]; - return 1 if $_[0]->{type_constraint}->check($_); + local $_ = $value; + return 1 if $tc->check($value); - my $self = shift; - $self->verify_type_constraint_error($self->name, $_, $self->{type_constraint}); + $self->verify_type_constraint_error($self->name, $value, $tc); } sub verify_type_constraint_error { my($self, $name, $value, $type) = @_; - $type = ref($type) eq 'ARRAY' ? join '|', map { $_->name } @{ $type } : $type->name; - my $display = defined($value) ? overload::StrVal($value) : 'undef'; - Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display"); + Carp::confess("Attribute ($name) does not pass the type constraint because: " . $type->get_message($value)); } sub coerce_constraint { ## my($self, $value) = @_;