7 package Test::MyMooseClass;
10 use MooseX::Types::Parameterizable qw(Parameterizable);
11 use MooseX::Types::Moose qw(Str Int);
12 use MooseX::Types -declare=>[qw(Varchar)];
14 ## Minor change from docs to avoid additional test dependencies
16 as Parameterizable[Str,Int],
18 my($string, $int) = @_;
19 $int >= length($string) ? 1:0;
22 has short_string => ( is => 'rw', isa => Varchar[5] );
25 my $obj = Test::MyMooseClass->new(short_string => 'four');
27 is $obj->short_string, 'four', 'attribute stored correctly';
30 eval { $obj->short_string('longer') };
32 like $@, qr/Attribute \(short_string\) does not pass the type constraint/, 'fails on longer string with correct error message';