diff --git a/lib/class/OptionRegistry.js b/lib/class/OptionRegistry.js index 5736c386c65fbfe2794bad7d5815cc0b3fc2291d..3ab371a173438a9d4eef963c21b773d5fccdd83c 100644 Binary files a/lib/class/OptionRegistry.js and b/lib/class/OptionRegistry.js differ diff --git a/lib/types/object.js b/lib/types/object.js index c64b062589d7f6bf2bcc99cf09ef63bd23074448..07726e069d5aad679c375a32a1566c59d691ee64 100644 Binary files a/lib/types/object.js and b/lib/types/object.js differ diff --git a/ts/class/OptionRegistry.ts b/ts/class/OptionRegistry.ts index 3af4e746b9c195113034f5a46079725a192771c5..e1dd9f8727e79739b75ace57a00ffb364b9c311c 100644 --- a/ts/class/OptionRegistry.ts +++ b/ts/class/OptionRegistry.ts @@ -12,6 +12,7 @@ class OptionRegistry extends Registry<Option> { this.data['failOnInvalidTypes'] = true; this.data['defaultInvalidTypeProduct'] = null; this.data['useDefaultValue'] = false; + this.data['requiredOnly'] = false; this.data['maxItems'] = null; this.data['maxLength'] = null; this.data['defaultMinItems'] = 0; diff --git a/ts/types/object.ts b/ts/types/object.ts index 26747d59a853eab3a7d80b98bc4f1c9b0d7e686c..ffac5507556599ca868f99dd269a8f5c23fc96a9 100644 --- a/ts/types/object.ts +++ b/ts/types/object.ts @@ -35,6 +35,16 @@ var objectType: FTypeGenerator = function objectType(value: IObjectSchema, path, throw new ParseError('missing properties for:\n' + JSON.stringify(value, null, ' '), path); } + if (option('requiredOnly') === true) { + requiredProperties.forEach(function(key) { + if (properties[key]) { + props[key] = properties[key]; + } + }); + + return traverseCallback(props, path.concat(['properties']), resolve); + } + var min = Math.max(value.minProperties || 0, requiredProperties.length); var max = Math.max(value.maxProperties || random.number(min, min + 5));