Auth0 Home Blog Docs

How to access ValidationError object in Hooks?

auth0
api
management-api
#1

I am using the pre-user registration extensibility point to prevent the sign up based on certain conditions. I could prevent the sign up in the hooks but as we are using the Lock widget for the front end, we have to send the custom error message code so that the proper message is shown to the user if sign up fails.

We tried sending the ValidationError object with error code and created the error message with the same error code in languageDictionary of the lock options as follows:

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

cb(new ValidationError(‘user-error-code’, ‘User Error"’), response);
};

But somehow the hook does not have access to the ValidationError object and it throws an error. Is there a possibility to import ValidationError object in Hooks by importing some packages? Where can I find the detailed documentation for it?

Thank you.

#2

Hi @bhushan.chaudhari

Unfortunately, the pre-user registration hook does not currently expose error information to the authentication API, so the error will not reach Lock. This is known limitation at the moment, documented at the bottom of this doc: https://auth0.com/docs/hooks/guides/use-the-pre-user-registration-extensibility-point.

1 Like
#3

Thank you for the reply.

1 Like
closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.