Blacklist email domains - hook


I realized that it’s possible to make a pre-user registration hook on which I can check the e-mail for blacklisting. Correct me if that’s not possible.
I need to check the pre-registration email so it’s not, like, or
Is it possible to share an example of a pre-registration-hook that checks for blacklisted emails? I would also like to display a custom message in this case, rather than the standard “something went wrong”.

I found only the reverse example with whitelist, and not hook, but rule:

 function (user, context, callback) {
    var whitelist = ['', ''];
    var userHasAccess = whitelist.some(
      function (domain) {
        var emailSplit ='@');
        return emailSplit[emailSplit.length - 1].toLowerCase() === domain;

    if (!userHasAccess) {
      return callback(new UnauthorizedError('Access denied.'));

    return callback(null, user, context);