datumo
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -39,2 +39,3 @@ 'use strict'; | ||
let defaults = _ref$defaults === undefined ? true : _ref$defaults; | ||
let nullAsUndefined = _ref.nullAsUndefined; | ||
@@ -47,5 +48,7 @@ let target = {}; | ||
if (subProperties.some(property => typeof subData[property] !== 'undefined' || defaults && typeof subSchema[property]['default'] !== 'undefined')) { | ||
target[property] = constructData(subSchema, subData, { defaults: defaults }); | ||
target[property] = constructData(subSchema, subData, { | ||
defaults: defaults, nullAsUndefined: nullAsUndefined | ||
}); | ||
} else { | ||
target[property] = data.hasOwnProperty(property) ? data[property] : defaults ? schema[property]['default'] : undefined; | ||
target[property] = data.hasOwnProperty(property) && (!nullAsUndefined || data[property] !== null) ? data[property] : defaults ? schema[property]['default'] : undefined; | ||
} | ||
@@ -65,2 +68,3 @@ } | ||
let defaults = _ref2$defaults === undefined ? true : _ref2$defaults; | ||
let nullAsUndefined = _ref2.nullAsUndefined; | ||
@@ -101,3 +105,3 @@ let schema = this.constructor.schema; | ||
data = constructData(schema, data, { defaults: defaults }); | ||
data = constructData(schema, data, { defaults: defaults, nullAsUndefined: nullAsUndefined }); | ||
@@ -104,0 +108,0 @@ for (let property of Object.getOwnPropertyNames(schema)) { |
{ | ||
"name": "datumo", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Lightweight data modelling for Node.js", | ||
@@ -11,4 +11,4 @@ "main": "lib/index.js", | ||
"prepublish": "npm run compile", | ||
"test": "mocha test/**/*.es6 && npm run lint", | ||
"test-watch": "mocha test/**/*.es6 --watch", | ||
"test": "npm run compile && mocha test/**/*.es6 && npm run lint", | ||
"test-watch": "npm run compile && mocha test/**/*.es6 --watch", | ||
"lint": "eslint src/**/*.es6 test/**/*.es6 && echo Code looks good!" | ||
@@ -15,0 +15,0 @@ }, |
@@ -54,4 +54,4 @@ # datumo | ||
for quick-and-easy validation | ||
- [**Subclass models**](#subclassing) - easily create of models for subsets of | ||
your data | ||
- [**Subclass models**](#subclassing) - easily create models for subsets of your | ||
data | ||
- [**Extend models**](#extension) - take advantage of ES6 classes to easily | ||
@@ -138,3 +138,3 @@ extend models | ||
Say you have a model that allows for sensitive information. Or, perhaps, you | ||
Say you have a model that may contain sensitive information. Or, perhaps, you | ||
have a model that has all the data you need, but has a bit too much. With | ||
@@ -141,0 +141,0 @@ Datumo, it's easy to create a new model that has only the data you need. |
16882
161