perl - "ArrayRefOfHashrefs" subtype not working in Moose -


so have little sketch, trying hang of subtypes:

#!/usr/bin/perl # use strict; use warnings;  package foo; use moose; use moose::util::typeconstraints; use data::dumper;  subtype 'arrayrefofhashrefs' => 'arrayref[hashref]';  has 'thingy' => ( 'is' => 'ro', 'isa' => 'arrayrefofhashrefs' );  package main;  $foo = foo->new('thingy' => [{ 'id' => 12 }]);  # above produces:    use data::dumper; print dumper $foo->thingy; 

and when try run it, get:

attribute (thingy) not pass type constraint because: validation failed 'arrayrefofhashrefs' value array(0x7fda83028e08) @ /[path]/site_perl/5.18.4/darwin2level/moose/object.pm line 24

moose::object::new('foo', 'thingy', 'array(0x7fda83028e08)') called @ ../sketches/arrayrefofhashrefs.pl line 17

what doing wrong?

you have typo. hashref called hashref capital r. rest fine.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -