9 eval "use Declare::Constraints::Simple;";
10 plan skip_all => "Declare::Constraints::Simple is required for this test" if $@;
18 use_ok('Moose::Util::TypeConstraints');
24 use Moose::Util::TypeConstraints;
25 use Declare::Constraints::Simple -All;
27 # define your own type ...
28 type 'HashOfArrayOfObjects'
31 -values => IsArrayRef( IsObject ));
35 isa => 'HashOfArrayOfObjects',
38 # inline the constraints as anon-subtypes
41 isa => subtype('ArrayRef' => IsArrayRef(IsInt)),
48 my $hash_of_arrays_of_objs = {
50 foo2 => [ Bar->new, Bar->new ],
53 my $array_of_ints = [ 1 .. 10 ];
58 'bar' => $hash_of_arrays_of_objs,
59 'baz' => $array_of_ints,
61 } '... construction succeeded';
64 is_deeply($foo->bar, $hash_of_arrays_of_objs, '... got our value correctly');
65 is_deeply($foo->baz, $array_of_ints, '... got our value correctly');
69 } '... validation failed correctly';
72 $foo->bar({ foo => 3 });
73 } '... validation failed correctly';
76 $foo->bar({ foo => [ 1, 2, 3 ] });
77 } '... validation failed correctly';
81 } '... validation failed correctly';
85 } '... validation failed correctly';