quanstructor
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "quanstructor", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Exceptionally powerful object model builder for complex architectures", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -109,4 +109,7 @@ let { defined } = require('./lib/Statics') | ||
if ( this.specs[ prop ].Quanstructor ) | ||
return QUANSTRUCTORS[ this.specs[ prop ].Quanstructor ].validate( obj[prop] ) | ||
if ( this.specs[ prop ].Quanstructor ) { | ||
return _.isArray( obj[ prop ] ) | ||
? obj[ prop ].map( (item) => { return QUANSTRUCTORS[ this.specs[ prop ].Quanstructor ].validate( item ) } ) | ||
: QUANSTRUCTORS[ this.specs[ prop ].Quanstructor ].validate( obj[prop] ) | ||
} | ||
@@ -128,3 +131,5 @@ if ( !this.specs[ prop ].validation ) return | ||
if ( this.specs[ attrib ].Quanstructor ) | ||
res[ attrib ] = await QUANSTRUCTORS[ this.specs[ attrib ].Quanstructor ].build( obj[ attrib ], projection, options ) | ||
res[ attrib ] = _.isArray( obj[ attrib ] ) ? await Promise.all( | ||
obj[ attrib ].map( (item) => { return QUANSTRUCTORS[ this.specs[ attrib ].Quanstructor ].build( item, projection, options ) } ) | ||
) : await QUANSTRUCTORS[ this.specs[ attrib ].Quanstructor ].build( obj[ attrib ], projection, options ) | ||
else { | ||
@@ -178,6 +183,8 @@ let value = obj[attrib] || ( this.specs[ attrib ].hasOwnProperty('default') ? this.assigner.cloneObject( this.specs[ attrib ].default ) : v.defaultValue( this.specs[ attrib ].validation ) ) | ||
for (let attrib of this.views[ space ] ) { | ||
if ( this.specs[ attrib ].Quanstructor ) | ||
res[ attrib ] = await QUANSTRUCTORS[ this.specs[ attrib ].Quanstructor ].proto( projection, options ) | ||
else { | ||
let value = this.specs[ attrib ].hasOwnProperty('default') ? this.specs[ attrib ].default : v.defaultValue( this.specs[ attrib ].validation ) | ||
let value = this.specs[ attrib ].hasOwnProperty('default') ? this.specs[ attrib ].default : v.defaultValue( this.specs[ attrib ].validation ) | ||
if ( this.specs[ attrib ].Quanstructor ) { | ||
res[ attrib ] = _.isArray( value ) | ||
? [ await QUANSTRUCTORS[ this.specs[ attrib ].Quanstructor ].proto( projection, options ) ] | ||
: await QUANSTRUCTORS[ this.specs[ attrib ].Quanstructor ].proto( projection, options ) | ||
} else { | ||
if ( this.specs[ attrib ]._allowNull || defined(value) ) | ||
@@ -184,0 +191,0 @@ ref[ attrib ] = value |
@@ -61,7 +61,9 @@ const Quastructor = require( '../Quanstructor' ) | ||
employeeID: { validation: REQUIRED }, | ||
person: { space: SPACE_SUPP, Quanstructor: 'Person' } | ||
person: { space: SPACE_SUPP, Quanstructor: 'Person' }, | ||
people: { default: [], space: SPACE_SUPP, Quanstructor: 'Person' } | ||
} ) | ||
console.log( await Absoluter.build( { | ||
employeeID: '121212', | ||
person: PERSON_PROTO_DB | ||
person: PERSON_PROTO_DB, | ||
people: [ PERSON_PROTO_DB ] | ||
} ) ) | ||
@@ -68,0 +70,0 @@ } ) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17537
483