<!-- Please note this is an issue tracker, not a support forum. For general questions, please use StackOverflow or Slack. For bugs, please fill out the template below. --> ## What are you doing? <!-- Post a minimal, self-contained code sample that reproduces the issue, including models and associations --> ```js await User.bulkCreate([ { email: 'user1@example.com', password: '123', createdAt: new Date(), updatedAt: new Date(), }, ],{ validate: true}) // In model attribute: password: { type: dt.VIRTUAL, set: function (val) { this.setDataValue('password', val) }, validate: { len: [10,200], virtualFieldValidator: function() { console.log('---validator---') // never called return false; }, }, }, ``` ## What do you expect to happen? Expected Validation Error in promise Add a new option of bulkCreate to explicitly enable virtual field validators. ```js { validate: true, validateVirtual: true, } ``` Or implicitly enable virtual field validators whenever 'validate' is set to true ## What is actually happening? User records are successfully created since validators of virtual field are ignored Sequelize version: "4.38.1" **Note :** _Your issue may be ignored OR closed by maintainers if it's not tested against latest version OR does not follow issue template._
Activity
sushantdhiman commentedon Oct 10, 2018
This happens because we are using
tableAttributesfor settingoptions.fieldssequelize/lib/model.js
Line 2493 in 8a8366b
password(as VIRTUAL) from validationNot sure what are the implications of setting
options.fieldstorawAttributesbut we can at least pass full fields when doing validationsequelize/lib/model.js
Line 2536 in 8a8366b
fix(model): validate virtual attribute (sequelize#9947)
fix(model): validate virtual attribute (#9947) (#10085)