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

Commit 6717a4af by Sascha Depold

Merge pull request #706 from domasx2/milestones/2.0.0

2.0.0. Do not modify validator Array argument on validation
2 parents 8031211a 91112431
...@@ -108,6 +108,8 @@ var prepareValidationOfAttribute = function(value, details, validatorType, optio ...@@ -108,6 +108,8 @@ var prepareValidationOfAttribute = function(value, details, validatorType, optio
if (!Array.isArray(validatorArgs)) { if (!Array.isArray(validatorArgs)) {
validatorArgs = [validatorArgs] validatorArgs = [validatorArgs]
} else {
validatorArgs = validatorArgs.slice(0);
} }
// extract the error msg // extract the error msg
......
...@@ -368,5 +368,26 @@ describe(Helpers.getTestDialectTeaser("DaoValidator"), function() { ...@@ -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!