package Mymodule; { use Mouse; use Mouse::Util::TypeConstraints; use Socket; ... subtype 'my_timestamp', => as 'Str', => where { m/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/ }, => message { 'Not a valid timestamp. Expect: yyyy-mm-dd hh:mm' }; has 'timestamp' => ( is => 'ro', isa => 'my_timestamp' );