use v5.14; use strict; use warnings; package KeyAtom { use Moose; use MooseX::Types::Moose -all; has data => ( is => 'rw', isa => Str | RegexpRef , ); } package ValAtom { use Moose; use MooseX::Types::Moose -all; extends 'KeyAtom'; sub _existing_constraint { my ($class, $attr) = @_; return $class->meta->find_attribute_by_name($attr)->type_constraint; } has '+data' => ( isa => __PACKAGE__->_existing_constraint('data') | ArrayRef | HashRef, ); } ValAtom->new(data => 'Hello'); # Str ValAtom->new(data => qr{Hello}); # RegexpRef ValAtom->new(data => []); # ArrayRef ValAtom->new(data => {}); # HashRef ValAtom->new(data => \*STDOUT); # none of the above... crash!