praetorian
Advanced tools
Comparing version 0.1.10 to 0.2.0
@@ -341,11 +341,16 @@ /** | ||
if( _.isArray( json[levelKey] ) ) { | ||
// loop each element in the array and parse those as individual objects against their schema | ||
_.each( json[levelKey], function( arrayElement, loopCount ) { | ||
if( !_.isUndefined( arrayElement ) ) { | ||
parseJson( arrayElement, schema[levelKey].items, levelKey + '[' + loopCount + '].' ); | ||
} else { | ||
// in this instance, an element in the array was not passed at all , no harm done | ||
// i.e. name[0].initial was not passed but name[1].initial was | ||
} | ||
} ); | ||
// Does the schema say there should be items? | ||
if( schema[levelKey].items ) { | ||
// loop each element in the array and parse those as individual objects against their schema | ||
_.each( json[levelKey], function( arrayElement, loopCount ) { | ||
if( !_.isUndefined( arrayElement ) ) { | ||
parseJson( arrayElement, schema[levelKey].items, levelKey + '[' + loopCount + '].' ); | ||
} else { | ||
// in this instance, an element in the array was not passed at all , no harm done | ||
// i.e. name[0].initial was not passed but name[1].initial was | ||
} | ||
} ); | ||
} else { | ||
// Schema says no "items" and as the value is an array, happy with that | ||
} | ||
} else { | ||
@@ -352,0 +357,0 @@ // ERROR: this value should be an ARRAY but it's not (object of some other description?) |
{ | ||
"name": "praetorian", | ||
"version": "0.1.10", | ||
"version": "0.2.0", | ||
"description": "A structured JSON parser and validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
30879
10
528