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

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() {
}
return new Utils.CustomEventEmitter(function(emitter) {
self.hookValidate().error(function (err) {
return emitter.emit('error', err)
}).success(function() {
self.hookValidate({
skip: _.difference(Object.keys(self.rawAttributes), options.fields)
}).proxy(emitter, { events: ['error'] }).success(function() {
options.fields.forEach(function(field) {
if (self.dataValues[field] !== undefined) {
values[field] = self.dataValues[field]
......
......@@ -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) {
var username = '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!