parent
2b8b6719a7
commit
251798c711
|
@ -93,7 +93,7 @@ function applyStrictCheck(model, strict, data, inst, cb) {
|
||||||
key = keys[i];
|
key = keys[i];
|
||||||
if (props[key]) {
|
if (props[key]) {
|
||||||
result[key] = data[key];
|
result[key] = data[key];
|
||||||
} else if (strict) {
|
} else if (strict && strict !== 'filter') {
|
||||||
inst.__unknownProperties.push(key);
|
inst.__unknownProperties.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -633,6 +633,20 @@ describe('manipulation', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should remove unknown attributes when strict: filter',
|
||||||
|
function(done) {
|
||||||
|
Person.definition.settings.strict = 'filter';
|
||||||
|
Person.findById(person.id, function(err, p) {
|
||||||
|
if (err) return done(err);
|
||||||
|
p.updateAttributes({name: 'John', foo: 'bar'},
|
||||||
|
function(err, p) {
|
||||||
|
if (err) return done(err);
|
||||||
|
p.should.not.have.property('foo');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Prior to version 3.0 `strict: true` used to silently remove unknown properties,
|
// Prior to version 3.0 `strict: true` used to silently remove unknown properties,
|
||||||
// now return validationError upon unknown properties
|
// now return validationError upon unknown properties
|
||||||
it('should return error on unknown attributes when strict: true',
|
it('should return error on unknown attributes when strict: true',
|
||||||
|
|
|
@ -73,7 +73,7 @@ describe('Model class inheritance', function() {
|
||||||
relations: {patch: true},
|
relations: {patch: true},
|
||||||
};
|
};
|
||||||
|
|
||||||
// saving original getMergePolicy method
|
// saving original getMergePolicy method
|
||||||
let originalGetMergePolicy = base.getMergePolicy;
|
let originalGetMergePolicy = base.getMergePolicy;
|
||||||
|
|
||||||
// the injected getMergePolicy method captures the provided configureModelMerge option
|
// the injected getMergePolicy method captures the provided configureModelMerge option
|
||||||
|
|
Loading…
Reference in New Issue