package My::Types; use strict; use warnings; use parent 'Type::Library'; use Type::Utils; # gets you sugar, 'declare' etc. use Types::Standard qw/ Maybe Str Int /; declare 'OptInt', as Maybe[Int], message {'must be integer or nothing'}; declare 'OptStr', as Maybe[Str], message {'must be string or nothing'}; 1; #### package My::Class; use Moo; use My::Types qw/ :all /; has optional_numeric_arg => ( is => 'ro', isa => OptInt ); has optional_string_arg => ( is => 'ro', isa => OptStr ); 1;