From: gfx Date: Fri, 19 Feb 2010 07:08:54 +0000 (+0900) Subject: Add assert_valid() to Meta::TypeConstraint X-Git-Tag: 0.50_02~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=785080642e584152fc8d7e87d77f11c7483d3f14 Add assert_valid() to Meta::TypeConstraint --- diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index f6bdac8..dc34532 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -220,6 +220,15 @@ sub parameterize{ ); } +sub assert_valid { + my ($self, $value) = @_; + + if(!$self->_compiled_type_constraint->($value)){ + Carp::confess($self->get_message($value)); + } + return 1; +} + 1; __END__ diff --git a/t/040_type_constraints/failing/010_misc_type_tests.t b/t/040_type_constraints/010_misc_type_tests.t similarity index 100% rename from t/040_type_constraints/failing/010_misc_type_tests.t rename to t/040_type_constraints/010_misc_type_tests.t