# define your own type ...
type( 'HashOfArrayOfObjects',
+ {
where => IsHashRef(
-keys => HasLength,
-values => IsArrayRef(IsObject)
)
- );
+ } );
has 'bar' => (
is => 'rw',
# inline the constraints as anon-subtypes
has 'baz' => (
is => 'rw',
- isa => subtype( as => 'ArrayRef', where => IsArrayRef(IsInt) ),
+ isa => subtype( { as => 'ArrayRef', where => IsArrayRef(IsInt) } ),
);
package Bar;
$foo->bar({ foo => [ 1, 2, 3 ] });
} '... validation failed correctly';
-
dies_ok {
$foo->baz([ "foo" ]);
} '... validation failed correctly';
dies_ok {
$foo->baz({});
} '... validation failed correctly';
+