##
package MyClass;
use Moose;
use Moose::Util::TypeConstraints;
subtype 'StringWithDashes'
=> as 'Str'
=> where { /^[\w-]+$/ };
has 'fname' => (
is => 'rw',
isa => 'StringWithDashes'
);
has 'lname' => (
is => 'rw',
isa => 'StringWithDashes'
);
####
use Email::Valid;
has 'email' => (
is => 'rw',
isa => subtype('Str', where { Email::Valid->address($_) })
);