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

Commit 2ae6723d by Ruben Bridgewater Committed by Jan Aagaard Meier

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

* Fix type validations being to strict for dates

* Add changelog entry
1 parent b193ff7c
# Future
- [FIXED] Accept dates as string while using `typeValidation` [#6453](https://github.com/sequelize/sequelize/issues/6453)
# 4.0.0-1
- [CHANGED] Removed `modelManager` parameter from `Model.init()` [#6437](https://github.com/sequelize/sequelize/issues/6437)
- [FIXED] Made `Model.init()` behave like `sequelize.define()` (hooks are called and options have proper defaults) [#6437](https://github.com/sequelize/sequelize/issues/6437)
......
......@@ -429,7 +429,7 @@ DATE.prototype.toSql = function toSql() {
return 'DATETIME';
};
DATE.prototype.validate = function validate(value) {
if (!_.isDate(value)) {
if (!Validator.isDate(String(value))) {
throw new sequelizeErrors.ValidationError(util.format('%j is not a valid date', value));
}
......
......@@ -268,7 +268,8 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
name: Sequelize.STRING,
awesome: Sequelize.BOOLEAN,
number: Sequelize.DECIMAL,
uid: Sequelize.UUID
uid: Sequelize.UUID,
date: Sequelize.DATE
});
before(function () {
......@@ -297,6 +298,14 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
})).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 () {
return expect(User.create({
number: '2321312301230128391820831289123012'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!