subtype 'DNAString' => as Str => where { $_ && $_=~/^[AGCTN]+$/i} => message {"Not a DNA string: only AGCT or N allowed and cannot be empty"}; #### use MyApp::MooseX::MyTypes: has sequence => ( isa => 'DNAString', ); #### coerce 'DNAString' => from duck_type( ['seq'] ) => via { $_->seq }; #### use MyApp::MooseX::MyTypes: has sequence => ( isa => 'DNAString', coerce => 1, );