allow inlining if the type has been subsequently defined
[gitmo/MooseX-Types.git] / t / lib / TestLibrary.pm
CommitLineData
8af0a70d 1package TestLibrary;
2use warnings;
3use strict;
4
52d358e2 5use MooseX::Types::Moose qw( Str ArrayRef Int );
6use MooseX::Types
16ddefbf 7 -declare => [qw( NonEmptyStr IntArrayRef TwentyThree Foo2Alias )];
8af0a70d 8
9subtype NonEmptyStr,
10 as Str,
11 where { length $_ },
12 message { 'Str must not be empty' };
13
14coerce NonEmptyStr,
15 from Int,
16 via { "$_" };
17
18subtype IntArrayRef,
19 as ArrayRef,
20 where { not grep { $_ !~ /^\d+$/ } @$_ },
21 message { 'ArrayRef contains non-Int value' };
22
23coerce IntArrayRef,
24 from Int,
25 via { [$_] };
26
27subtype TwentyThree,
28 as Int,
29 where { $_ == 23 },
30 message { 'Int is not 23' };
31
16ddefbf 32subtype Foo2Alias,
33 as Str,
34 where { 1 };
35
8af0a70d 361;