1 package Mouse::Meta::TypeConstraint;
4 use overload '""' => sub { shift->{name} }, # stringify to tc name
10 my $name = $args{name} || '__ANON__';
12 my $check = $args{_compiled_type_constraint} or Carp::croak("missing _compiled_type_constraint");
13 if (ref $check eq 'Mouse::Meta::TypeConstraint') {
14 $check = $check->{_compiled_type_constraint};
19 _compiled_type_constraint => $check,
20 message => $args{message}
24 sub name { shift->{name} }
28 $self->{_compiled_type_constraint}->(@_);
32 return $_[0]->{message};
36 my ($self, $value) = @_;
37 if ( my $msg = $self->message ) {
39 return $msg->($value);
42 $value = ( defined $value ? overload::StrVal($value) : 'undef' );
44 "Validation failed for '"
46 . "' failed with value $value";
55 Mouse::Meta::TypeConstraint - The Mouse Type Constraint Metaclass
59 For the most part, the only time you will ever encounter an
60 instance of this class is if you are doing some serious deep
61 introspection. This API should not be considered final, but
62 it is B<highly unlikely> that this will matter to a regular