Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes invalid properties getting saved #644

  • Loading branch information...
commit 0224d894275bfa193be9a5277d9443c55bd2ba0e 1 parent ccc9f64
Nathan White nw authored aheckmann committed

Showing 2 changed files with 6 additions and 0 deletions. Show diff stats Hide diff stats

  1. +5 0 lib/document.js
  2. +1 0  lib/schema.js
5 lib/document.js
@@ -28,6 +28,9 @@ function Document (obj, fields) {
28 28 if (!this._events) this._events = {};
29 29 this.setMaxListeners(0);
30 30
  31 + this._strictMode = !this.options.lax;
  32 + if(!fields && 'boolean' === typeof fields) this._strictMode = true;
  33 +
31 34 this._doc = this.buildDoc(fields);
32 35 this._activePaths = new ActiveRoster();
33 36 var self = this;
@@ -280,6 +283,8 @@ Document.prototype.set = function (path, val, type) {
280 283 if (null != path[key] && 'Object' === path[key].constructor.name
281 284 && !(this._path(prefix + key) instanceof MixedSchema)) {
282 285 this.set(path[key], prefix + key);
  286 + } else if(this._strictMode == true){
  287 + if(this._path(prefix + key) !== undefined) this.set(prefix + key, path[key]);
283 288 } else if (undefined !== path[key]) {
284 289 this.set(prefix + key, path[key]);
285 290 }
1  lib/schema.js
@@ -31,6 +31,7 @@ function Schema (obj, options) {
31 31 this.options = utils.options({
32 32 safe: true
33 33 , 'use$SetOnSave': true
  34 + , lax: true
34 35 }, options);
35 36
36 37 // build paths

0 comments on commit 0224d89

Please sign in to comment.
Something went wrong with that request. Please try again.