How to access ValidationError object in Hooks?

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.

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: Pre-User Registration.

1 Like

Thank you for the reply.

1 Like

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