Skip to content
Snippets Groups Projects
Commit e0f08e98 authored by Alvaro Cabrera's avatar Alvaro Cabrera
Browse files

Basic support for alwaysFakeOptionals option; fixes #154

parent dc267d7b
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -14,6 +14,7 @@ class OptionRegistry extends Registry<Option> { ...@@ -14,6 +14,7 @@ class OptionRegistry extends Registry<Option> {
this.data['useDefaultValue'] = false; this.data['useDefaultValue'] = false;
this.data['maxItems'] = null; this.data['maxItems'] = null;
this.data['maxLength'] = null; this.data['maxLength'] = null;
this.data['alwaysFakeOptionals'] = false;
} }
} }
......
...@@ -2,6 +2,7 @@ import container = require('../class/Container'); ...@@ -2,6 +2,7 @@ import container = require('../class/Container');
import random = require('../core/random'); import random = require('../core/random');
import words = require('../generators/words'); import words = require('../generators/words');
import utils = require('../core/utils'); import utils = require('../core/utils');
import option = require('../api/option');
import ParseError = require('../core/error'); import ParseError = require('../core/error');
var randexp = container.get('randexp'); var randexp = container.get('randexp');
...@@ -44,7 +45,8 @@ var objectType: FTypeGenerator = function objectType(value: IObjectSchema, path, ...@@ -44,7 +45,8 @@ var objectType: FTypeGenerator = function objectType(value: IObjectSchema, path,
}); });
// properties are read from right-to-left // properties are read from right-to-left
var _props = requiredProperties.slice(0, random.number(min, max)); var _props = option('alwaysFakeOptionals') ? requiredProperties
: requiredProperties.slice(0, random.number(min, max));
_props.forEach(function(key) { _props.forEach(function(key) {
// first ones are the required properies // first ones are the required properies
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment