How to restrict sign ups for certain users

Thank you. 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 from the hook to detect certain scenario.

Just for the testing purposes, 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.

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. Do i need to import anything or am I missing something here?