2023-03-24 11:11:42 +00:00
|
|
|
module.exports = function(Self) {
|
2023-03-28 08:07:14 +00:00
|
|
|
Self.validatesPresenceOf('text', isEnabled, {message: 'Description cannot be blank'});
|
2023-03-24 11:11:42 +00:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
};
|