1 package DecoratorLibrary;
3 use MooseX::Types::Moose qw( Str ArrayRef HashRef Int );
18 subtype MyArrayRefBase,
21 coerce MyArrayRefBase,
23 via {[split(',', $_)]};
25 subtype MyArrayRefInt01,
32 ## We can change this when the .61 Moose comes out. When that happens we will
33 ## have the correct patch to Moose::Meta::TypeConstraint::Parameterized to let
34 ## us support parameterizing parameterized subtypes. When we get this we can
35 ## then replace the where clause with:
37 ##as MyArrayRefInt01[BiggerInt];
39 subtype SubOfMyArrayRefInt01,
43 foreach my $int (@$_) {
44 $ok_or_not = $int>10 ? 1:0
49 coerce MyArrayRefInt01,
51 via {[split('\.',$_)]},
53 via {[sort values(%$_)]};
55 subtype MyArrayRefInt02,
56 as MyArrayRefBase[Int];
58 subtype MyHashRefOfInts,
61 subtype MyHashRefOfStr,
64 coerce MyArrayRefInt02,
66 via {[split(':',$_)]},
68 via {[sort values(%$_)]},
70 via {[ sort map { length $_ } values(%$_) ]},
71 from HashRef[ArrayRef],
72 via {[ sort map { @$_ } values(%$_) ]};
74 subtype StrOrArrayRef,
77 subtype AtLeastOneInt,
82 (qw/Programming Teaching Banking/);