Friday, 2 June 2017

Sequelize validation throws 'undefined' error

I'm trying out Sequelize's built in validators. Model definition:module.exports = function(sequelize, DataTypes) { var Device = sequelize.define('Device', { model_name: { type: DataTypes.STRING, validate: { notNull: { args: true, msg: 'Model name needed' } } } ... with bulkCreateDevice.bulkCreate(csvOutput, { validate: true }) .then(function() { console.log('Records inserted into database') }) .catch(function(err) { console.log('Error encountered: ' + err.message) }) To test, I tried to insert a blank field for model_name. I tried also to include a proper model name.Both scenarios above produce an error that is simply [object Object]. I could not seem to figure out why. Hope someone can shed some light here!Note: the error goes away if i remove validate from the Model entirely.

Submitted June 02, 2017 at 08:18AM by raccoonranger73

No comments:

Post a Comment