praetorian
Advanced tools
{ | ||
"FIELD_REQUIRED_BUT_NOT_FOUND": "Required but not found", | ||
"TYPE_REQUIRED_BUT_NOT_FOUND" : "Type required but not found", | ||
"FIELD_REQUIRED_BUT_NOT_FOUND": "Field required but not found", | ||
"HASH_INVALID": "Hash not present or invalid", | ||
@@ -4,0 +5,0 @@ "HASH_VALUE_NOT_A_OBJECT": "Hash value not an object", |
{ | ||
"FIELD_REQUIRED_BUT_NOT_FOUND": "Requis mais non trouvé", | ||
"TYPE_REQUIRED_BUT_NOT_FOUND" : "Type requis, mais ne pas trouvé", | ||
"FIELD_REQUIRED_BUT_NOT_FOUND": "Champ requis mais pas trouvé", | ||
"HASH_INVALID": "** Hash not present or invalid **", | ||
@@ -4,0 +5,0 @@ "HASH_VALUE_NOT_A_OBJECT": "Hash value not an object", |
@@ -222,4 +222,8 @@ /** | ||
if( json[levelKey] ) { | ||
// schema says type ARRAY and we have "items" or OBJECT and we have "properties" we continue | ||
if( ( !_.isUndefined( levelValue.items ) ) && ( levelValue.type === primitiveTypes.ARRAY ) && _.isArray( json[levelKey] ) ) { | ||
// We need to ensure that "type" is always passed in. | ||
if( !levelValue.type ) { | ||
addError( elementPrefix + levelKey, self.options.messages.TYPE_REQUIRED_BUT_NOT_FOUND ); | ||
} else if( ( !_.isUndefined( levelValue.items ) ) && ( levelValue.type === primitiveTypes.ARRAY ) && _.isArray( json[levelKey] ) ) { | ||
// schema says type ARRAY and we have "items" or OBJECT and we have "properties" we continue | ||
_.each( json[levelKey], function( jsonValue, jsonKey ) { | ||
@@ -235,3 +239,3 @@ if( !_.isUndefined( jsonValue ) ) { | ||
requiredJson( json[levelKey], levelValue.properties, elementPrefix + levelKey + '.' ); | ||
} | ||
} | ||
} | ||
@@ -238,0 +242,0 @@ |
{ | ||
"name": "praetorian", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A structured JSON parser and validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,3 +28,3 @@ # Praetorian | ||
Praetorian supports the following data types "out of the box", `boolean`, `date`, `decimal`, `integer`, `string`. By defining these in your schema against a JSON key, Praetorian will ensure the value passed in the JSON data is of that type. | ||
Praetorian supports the following data types "out of the box", `boolean`, `date`, `decimal`, `integer`, `string`. By defining these in your schema against a JSON key, Praetorian will ensure the value passed in the JSON data is of that type. Types are required. | ||
@@ -31,0 +31,0 @@ #### Boolean |
27755
1.3%445
1.14%