Add assert_valid() to Meta::TypeConstraint
gfx [Fri, 19 Feb 2010 07:08:54 +0000 (16:08 +0900)]
lib/Mouse/Meta/TypeConstraint.pm
t/040_type_constraints/010_misc_type_tests.t [moved from t/040_type_constraints/failing/010_misc_type_tests.t with 100% similarity]

index f6bdac8..dc34532 100644 (file)
@@ -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__