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

fix null values when allowNull

1 parent e329f903
...@@ -244,6 +244,12 @@ DaoValidator.prototype._customValidators = function() { ...@@ -244,6 +244,12 @@ DaoValidator.prototype._customValidators = function() {
*/ */
DaoValidator.prototype._builtinAttrValidate = function(value, field) { DaoValidator.prototype._builtinAttrValidate = function(value, field) {
var self = this; var self = this;
// check if value is null (if null not allowed the Schema pass will capture it)
if (value === null) {
return Promise.resolve();
}
// Promisify each validator // Promisify each validator
var validators = []; var validators = [];
Utils._.forIn(this.modelInstance.validators[field], function(test, Utils._.forIn(this.modelInstance.validators[field], function(test,
......
...@@ -427,18 +427,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -427,18 +427,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
StringIsNullOrUrl.sync({ force: true }).success(function() { StringIsNullOrUrl.sync({ force: true }).success(function() {
StringIsNullOrUrl.create({ str: null }).success(function(str1) { StringIsNullOrUrl.create({ str: null }).success(function(str1) {
expect(str1.str).to.be.null expect(str1.str).to.be.null
StringIsNullOrUrl.create({ str: 'http://sequelizejs.org' }).success(function(str2) { StringIsNullOrUrl.create({ str: 'http://sequelizejs.org' }).success(function(str2) {
expect(str2.str).to.equal('http://sequelizejs.org') expect(str2.str).to.equal('http://sequelizejs.org')
StringIsNullOrUrl.create({ str: '' }).error(function(err) { StringIsNullOrUrl.create({ str: '' }).error(function(err) {
expect(err).to.exist expect(err).to.exist
expect(err.str[0]).to.match(/Validation isURL failed/) expect(err.str[0].message).to.match(/Validation isURL failed/)
done() done()
}) })
}) })
}) }).error(done)
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!