"ArrayRefOfHashrefs"子类型在Moose中不起作用

Kit*_*ers 1 perl moose

所以我有这个小草图,试图获得子类型的悬念:

#!/usr/bin/perl
#
use strict;
use warnings;

package Foo;
use Moose;
use Moose::Util::TypeConstraints;
use Data::Dumper;

subtype 'ArrayRefOfHashrefs' => as 'ArrayRef[Hashref]';

has 'thingy' => ( 'is' => 'ro', 'isa' => 'ArrayRefOfHashrefs' );

package main;

my $foo = Foo->new('thingy' => [{ 'id' => 12 }]);

# The above produces: 


use Data::Dumper;
print Dumper $foo->thingy;
Run Code Online (Sandbox Code Playgroud)

当我尝试运行它时,我得到:

属性(thingy)不传递类型约束,因为:对于'ArrayRefOfHashrefs',值为ARRAY(0x7fda83028e08)的值为/[PATH] /site_perl/5.18.4/darwin2level/Moose/Object.pm第24行的验证失败

Moose :: Object :: new('Foo','thingy','ARRAY(0x7fda83028e08)')在../sketches/arrayrefofhashrefs.pl第17行调用

我究竟做错了什么?

sim*_*que 5

你有一个错字.在Hashref被称为HashRef大写[R .剩下的很好.