constraining_value => $args,
parent_type_constraint=>$self->parent_type_constraint,
constraining_value_type_constraint => $self->constraining_value_type_constraint,
- ($self->has_message ? (message => $self->message) : ()),
+ ($self->has_message ? (message => sub { $self->message->( @_, $args ) } ) : ()),
);
}
}
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More;
+use MooseX::Types -declare=>[qw( SizedArray )];
+use MooseX::Types::Parameterizable qw(Parameterizable);
+use MooseX::Types::Moose qw( Int ArrayRef );
+
+ok subtype(
+ SizedArray,
+ as Parameterizable[ArrayRef,Int],
+ where {
+ my ($value, $max) = @_;
+ @$value > $max
+ },
+ message {
+ my($value, $max) = @_;
+ return sprintf('%d > %d', scalar(@$value), $max);
+ }
+), 'Created parameterized type';
+
+is SizedArray([3])->get_message([1..4]), q{4 > 3}, 'custom message';
+
+done_testing;