const md5 = require('md5'); module.exports = function(Self) { // Validations Self.validatesUniquenessOf('name', { message: 'Ya existe un usuario con ese nombre' }); Self.observe('before save', (ctx, next) => { if (ctx.currentInstance && ctx.currentInstance.id && ctx.data && ctx.data.password) { ctx.data.password = md5(ctx.data.password); } next(); }); };