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

Commit 6e44b593 by Ruben Bridgewater Committed by Sushant

Fix type validations being to strict for dates (#6453)

* Fix type validations being to strict for dates

* Add changelog entry
1 parent 37a776ea
# Future
- [FIXED] Accept dates as string while using `typeValidation` [#6453](https://github.com/sequelize/sequelize/issues/6453)
# 3.24.1 # 3.24.1
- [FIXED] Add `parent`, `original` and `sql` properties to `UniqueConstraintError` - [FIXED] Add `parent`, `original` and `sql` properties to `UniqueConstraintError`
......
...@@ -458,7 +458,7 @@ DATE.prototype.toSql = function() { ...@@ -458,7 +458,7 @@ DATE.prototype.toSql = function() {
return 'DATETIME'; return 'DATETIME';
}; };
DATE.prototype.validate = function(value) { DATE.prototype.validate = function(value) {
if (!_.isDate(value)) { if (!Validator.isDate(String(value))) {
throw new sequelizeErrors.ValidationError(util.format('%j is not a valid date', value)); throw new sequelizeErrors.ValidationError(util.format('%j is not a valid date', value));
} }
......
...@@ -274,7 +274,8 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() { ...@@ -274,7 +274,8 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
name: Sequelize.STRING, name: Sequelize.STRING,
awesome: Sequelize.BOOLEAN, awesome: Sequelize.BOOLEAN,
number: Sequelize.DECIMAL, number: Sequelize.DECIMAL,
uid: Sequelize.UUID uid: Sequelize.UUID,
date: Sequelize.DATE
}); });
before(function () { before(function () {
...@@ -303,6 +304,14 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() { ...@@ -303,6 +304,14 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
})).not.to.be.rejected; })).not.to.be.rejected;
}); });
it('should allow dates as a string', function() {
return expect(User.find({
where: {
date: '2000-12-16'
}
})).not.to.be.rejected;
});
it('should allow decimal big numbers as a string', function () { it('should allow decimal big numbers as a string', function () {
return expect(User.create({ return expect(User.create({
number: '2321312301230128391820831289123012' number: '2321312301230128391820831289123012'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!