castor-load-custom
Advanced tools
Comparing version 1.4.0 to 1.4.1
11
index.js
@@ -105,15 +105,16 @@ /*jshint node:true, laxcomma:true*/ | ||
if (options.schema[key].path) { | ||
var valp; | ||
if (typeof options.schema[key].path === 'string') { | ||
values[key] = objectPath.get(input, options.schema[key].path); | ||
valp = objectPath.get(input, options.schema[key].path); | ||
} | ||
else if (Array.isArray(options.schema[key].path)) { | ||
if (options.schema[key].coalesce) { | ||
values[key] = objectPath.coalesce(input, options.schema[key].path); | ||
valp = objectPath.coalesce(input, options.schema[key].path); | ||
} | ||
else { | ||
values[key] = options.schema[key].path.map(function(i) { return objectPath.get(input, i); }).filter(function(i) { return (i !== '' && i !== undefined && i !== null); }); | ||
valp = options.schema[key].path.map(function(i) { return objectPath.get(input, i); }).filter(function(i) { return (i !== '' && i !== undefined && i !== null); }); | ||
} | ||
} | ||
if (values[key] === undefined) { | ||
values[key] = ''; | ||
if (valp !== undefined && valp !== null) { | ||
values[key] = valp; | ||
} | ||
@@ -120,0 +121,0 @@ } |
{ | ||
"name": "castor-load-custom", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "custom loader for castor", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
15467
201