use Moose::Util::TypeConstraints; subtype 'Net::IP::Address', as 'Str', where { NetAddr::IP->new($_, '255.255.255.255') }; no Moose::Util::TypeConstraints;