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.