#!/usr/bin/perl package Test::HashK; use Moose; use Moose::Util::TypeConstraints; enum 'colors', [qw(red green blue)]; has scores => ( is => 'rw', isa => 'HashRef[colors]', default => sub{{}} ); # I want the allowed *keys* to be colors 1; #### #!/usr/bin/perl use strict; use Test::HashK; my $hk=Test::HashK->new; $hk->scores->{'red'} = 53; $hk->scores->{'black'} = 100; $hk->scores->{1} = 'blue'; $hk->scores->{2} = 'dinosaur';