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

Apply defaultMinItems option; fixes #170

parent ab2a1e46
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> {
this.data['useDefaultValue'] = false;
this.data['maxItems'] = null;
this.data['maxLength'] = null;
this.data['defaultMinItems'] = 0;
this.data['defaultRandExpMax'] = 10;
this.data['alwaysFakeOptionals'] = false;
}
......
......@@ -60,6 +60,13 @@ var arrayType: FTypeGenerator = function arrayType(value: IArraySchema, path: Sc
var minItems = value.minItems;
var maxItems = value.maxItems;
if (option('defaultMinItems') && minItems === undefined) {
// fix boundaries
minItems = !maxItems
? option('defaultMinItems')
: Math.min(option('defaultMinItems'), maxItems);
}
if (option('maxItems')) {
// Don't allow user to set max items above our maximum
if (maxItems && maxItems > option('maxItems')) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment