I would like to respond with a 406, when the user tries to set their password to a length less than 8 characters. I am doing this validation in the beforeCreate
function on my model. But Sails responds with a 500 and an Internal Server Error
message. Is there anyway to access the response object and respond with my own response?
module.exports = {
beforeCreate: function (attrs, next) {
if (attrs.password.length < PASS_MIN_LENGTH) {
return next({status: 406, message: "Password must be at least 8 characters"});
}
next();
},
... // Model definition below
};