Email minimum character count requirement

Hi, I’m working on implementing some client requirements for login credentials.

Is there a way to enforce a minimum of four characters in the attached email field?

I know this request is a bit silly, I’m not sure if you can even have an email that is less then four characters. Doing due diligence and asking though!!

Screen Shot 2020-11-04 at 10.24.07 AM|572x500

Hey there!

Yep it’s a bit weird and kinda impossible :smiley: (to have such short email) but let me check and get back to you soon!


I believe you can enforce this check using a rule. Verify the input fields in rule and validate according to your requirement and let the flow complete or raise error as per requirement.

@rashid779939 can you actually share an exact code snippet how you would do it?

Hm, I was under the impression that rules only run after a successful login attempt. So could you use them to validate an input field like that?

Also I’m a little unsure if rules are run for the user creation form in the original post.

Yep that is correct. Rules are run upon successful login attempt.

Yeah that’s true, but Auth0 provides a extensive handy features like you can also use per-registration hook to validate the input fields from user.


You can find more information about it here:


Thanks for the pointers. Here’s what I ended up with. If you happen to take a look let me know if you notice any glaring issues, this is my first one of these hooks.

module.exports = function (user, context, cb) {
  const response = {};

  // Deny the user's registration and send a localized message to New Universal Login
  if ( < 4) {
   en: 'Email must be atleast four characters long.',
   es: 'El correo electrónico debe tener al menos cuatro caracteres.'

 const localizedMessage = LOCALIZED_MESSAGES[context.renderLanguage] || LOCALIZED_MESSAGES['en'];
 return cb(new PreUserRegistrationError('Denied user registration in Pre User Registration Hook', localizedMessage));

  cb(null, response);

Thanks for sharing it! Looks totally fine!

Actually, testing this code above did work in the hooks code editor however now when I try and create a new user I get the following error on the user create form after attempting to submit.

Error! Sandbox Error: Extensibility error

If I disable the pre-registration hook then the above error goes away.