不要怂,就是干,撸起袖子干!

Commit 8b0b03c8 by Jan Aagaard Meier

Dont validate fields that are not saved. Closes #1449

1 parent 8536013f
Showing with 12 additions and 3 deletions
...@@ -305,9 +305,9 @@ module.exports = (function() { ...@@ -305,9 +305,9 @@ module.exports = (function() {
} }
return new Utils.CustomEventEmitter(function(emitter) { return new Utils.CustomEventEmitter(function(emitter) {
self.hookValidate().error(function (err) { self.hookValidate({
return emitter.emit('error', err) skip: _.difference(Object.keys(self.rawAttributes), options.fields)
}).success(function() { }).proxy(emitter, { events: ['error'] }).success(function() {
options.fields.forEach(function(field) { options.fields.forEach(function(field) {
if (self.dataValues[field] !== undefined) { if (self.dataValues[field] !== undefined) {
values[field] = self.dataValues[field] values[field] = self.dataValues[field]
......
...@@ -780,6 +780,15 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -780,6 +780,15 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
it('only validates fields in passed array', function (done) {
this.User.build({
validateTest: 'cake', // invalid, but not saved
validateCustom: '1'
}).save(['validateCustom']).success(function () {
done()
})
})
it("stores an entry in the database", function(done) { it("stores an entry in the database", function(done) {
var username = 'user' var username = 'user'
, User = this.User , User = this.User
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!