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

Commit 91112431 by Domas Lapinskas

Do not modify validator Array argument on validation

1 parent 8031211a
......@@ -108,6 +108,8 @@ var prepareValidationOfAttribute = function(value, details, validatorType, optio
if (!Array.isArray(validatorArgs)) {
validatorArgs = [validatorArgs]
} else {
validatorArgs = validatorArgs.slice(0);
}
// extract the error msg
......
......@@ -368,5 +368,26 @@ describe(Helpers.getTestDialectTeaser("DaoValidator"), function() {
})
})
})
it('validates model with a validator whose arg is an Array successfully twice in a row', function(done){
var Foo = this.sequelize.define('Foo' + Math.random(), {
bar: {
type: Sequelize.STRING,
validate: {
isIn: [['a', 'b']]
}
}
}), foo;
foo = Foo
.build({bar:'a'});
foo.validate().success(function(errors){
expect(errors).not.toBeDefined()
foo.validate().success(function(errors){
expect(errors).not.toBeDefined()
done();
});
});
});
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!