package Person; use Moose; use Moose::Util::TypeConstraints; enum Gender => qw(female male); has sex => ( is => 'rw', isa => 'Gender' ); package main; my $M = Person->new( sex => '' ); # fails #$M->sex( 'please' ); # fails #### $ perl -MMoose -E 'say $Moose::VERSION' 0.44 $ perl -MMoose::Util::TypeConstraints -E 'say $Moose::Util::TypeConstraints::VERSION' 0.22 $ perl -v This is perl, v5.10.0 built for x86_64-linux-gnu-thread-multi