# WWWGoogleContactsTypeEmail class_type WWWGoogleContactsTypeEmail, { class => 'WWW::Google::Contacts::Type::Email', }; # GooglePrimaryEmail subtype GooglePrimaryEmail, as EmailAddress, message { 'validation failed for: '. Dumper $_; }; coerce GooglePrimaryEmail, from ArrayRef[WWWGoogleContactsTypeEmail], via { my $p = (grep { $_->{primary} } @$_)[0]; $p = $p ? $p->{value} : @$_->[0]{value}; # no prim email -> take first address return $p; };