subset Email of Pair where .key ~~ 'email' && .value ~~ /'@'/;
subset AccountID of Pair where .key ~~ 'accountid' && .value ~~ Int && .value.chars ~~ 12;
subset ID of Any where Email|AccountID;
multi sub foo(Str $email --> ID) { email => $email };
multi sub foo(Int $accountid --> ID) { accountid => $accountid };
my $id1 = foo('p@p6.org');
say "id1 is Email? {$id1 ~~ Email}";
say "id1 is AccountID? {$id1 ~~ AccountID}";
my $id2 = foo(123123123123);
say "id2 is Email? {$id2 ~~ Email}";
say "id2 is AccountID? {$id2 ~~ AccountID}";