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

Apply defaultRandExpMax option; fix

parent e0f08e98
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.
import RandExp = require('randexp'); import RandExp = require('randexp');
import option = require('../api/option');
// set maximum default, see #193 // set maximum default, see #193
RandExp.prototype.max = 10; RandExp.prototype.max = 10;
...@@ -52,7 +53,17 @@ class Container { ...@@ -52,7 +53,17 @@ class Container {
if (typeof this.registry[name] === 'undefined') { if (typeof this.registry[name] === 'undefined') {
throw new ReferenceError('"' + name + '" dependency doesn\'t exist.'); throw new ReferenceError('"' + name + '" dependency doesn\'t exist.');
} else if (name === 'randexp') { } else if (name === 'randexp') {
return this.registry['randexp'].randexp; var RandExp_ = this.registry['randexp'];
// wrapped generator
return function (pattern): string {
var re = new RandExp_(pattern);
// apply given setting
re.max = option('defaultRandExpMax');
return re.gen();
};
} }
return this.registry[name]; return this.registry[name];
} }
......
import Registry = require('./Registry'); import Registry = require('./Registry');
type Option = boolean; type Option = boolean|number;
/** /**
* This class defines a registry for custom formats used within JSF. * This class defines a registry for custom formats used within JSF.
...@@ -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['defaultRandExpMax'] = 10;
this.data['alwaysFakeOptionals'] = false; this.data['alwaysFakeOptionals'] = false;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment