module.exports = function(Self) { Self.validatesPresenceOf('text', isEnabled, {message: 'Description cannot be blank'}); function isEnabled(err) { if (!this.text) err(); } Self.observe('before save', async function(ctx) { ctx.instance.created = new Date(); let token = ctx.options.accessToken; let userId = token && token.userId; ctx.instance.userFk = userId; }); };