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

watch for custom built-in validator 'notNULL'

1 parent 66678390
...@@ -245,7 +245,8 @@ DaoValidator.prototype._customValidators = function() { ...@@ -245,7 +245,8 @@ 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) // check if value is null (if null not allowed the Schema pass will capture it)
if (value === null || typeof value === 'undefined') { if (!('notNull' in this.modelInstance.validators[field]) &&
(value === null || typeof value === 'undefined')) {
return Promise.resolve(); return Promise.resolve();
} }
......
...@@ -968,12 +968,12 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -968,12 +968,12 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
Tasks.bulkCreate([ Tasks.bulkCreate([
{name: 'foo', code: '123'}, {name: 'foo', code: '123'},
{code: '1234'}, {code: '1234'},
{name: 'bar', code: '1'} {name: 'bar', code: '1'}
], { validate: true }).error(function(errors) { ], { validate: true }).error(function(errors) {
expect(errors).to.not.be.null expect(errors).to.not.be.null
expect(errors).to.be.instanceof(Array) expect(errors).to.be.an('Array')
expect(errors).to.have.length(2) expect(errors).to.have.length(2)
expect(errors[0].record.code).to.equal('1234') expect(errors[0].record.code).to.equal('1234')
expect(errors[0].errors.name[0].message).to.equal('name cannot be null') expect(errors[0].errors.name[0].message).to.equal('name cannot be null')
expect(errors[1].record.name).to.equal('bar') expect(errors[1].record.name).to.equal('bar')
expect(errors[1].record.code).to.equal('1') expect(errors[1].record.code).to.equal('1')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!