From: Dave Rolsky Date: Fri, 27 Mar 2009 21:01:51 +0000 (-0500) Subject: Always use verify_against_type_constraint to check attribute value X-Git-Tag: 0.73_01~51 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1a41ab50a6fcb4c159bddbec3a95bcad16cc4f4;p=gitmo%2FMoose.git Always use verify_against_type_constraint to check attribute value validity (this doesn't fix perigrin's bug though) --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 1330952..36acd78 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -481,19 +481,11 @@ sub set_value { $self->throw_error("Attribute ($attr_name) is required", object => $instance); } - if ($self->has_type_constraint) { - - my $type_constraint = $self->type_constraint; - - if ($self->should_coerce) { - $value = $type_constraint->coerce($value); - } - $type_constraint->_compiled_type_constraint->($value) - || $self->throw_error("Attribute (" - . $self->name - . ") does not pass the type constraint because " - . $type_constraint->get_message($value), object => $instance, data => $value); + my $type_constraint = $self->type_constraint; + if ($self->should_coerce && $type_constraint->has_coercion) { + $value = $type_constraint->coerce($value); } + $self->verify_against_type_constraint($value, instance => $instance); my $meta_instance = Class::MOP::Class->initialize(blessed($instance)) ->get_meta_instance;