diff --git a/lib/class/Container.js b/lib/class/Container.js index daf2998c01b48cef224c4e3e8ecbf8bf041216d7..132428e891309bea2eedc85cd55a1706e234a0df 100644 Binary files a/lib/class/Container.js and b/lib/class/Container.js differ diff --git a/lib/class/OptionRegistry.js b/lib/class/OptionRegistry.js index 47a41f68d6b4dae3ae957ee2c74b5c8adf17500f..bf56c1ff7b7d18b722a7f2b990b33c4729d0e3d0 100644 Binary files a/lib/class/OptionRegistry.js and b/lib/class/OptionRegistry.js differ diff --git a/ts/class/Container.ts b/ts/class/Container.ts index 13cad00865b212d514b151790dc4fa19ad6da498..8323c1851668268390ba32aef34e2cb4ec835874 100644 --- a/ts/class/Container.ts +++ b/ts/class/Container.ts @@ -1,4 +1,5 @@ import RandExp = require('randexp'); +import option = require('../api/option'); // set maximum default, see #193 RandExp.prototype.max = 10; @@ -52,7 +53,17 @@ class Container { if (typeof this.registry[name] === 'undefined') { throw new ReferenceError('"' + name + '" dependency doesn\'t exist.'); } 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]; } diff --git a/ts/class/OptionRegistry.ts b/ts/class/OptionRegistry.ts index f663dafd941c1dbf14e67c8b043c7566cd742d63..4120800c848f05aa30e88aa24ebd56c32414898c 100644 --- a/ts/class/OptionRegistry.ts +++ b/ts/class/OptionRegistry.ts @@ -1,6 +1,6 @@ import Registry = require('./Registry'); -type Option = boolean; +type Option = boolean|number; /** * This class defines a registry for custom formats used within JSF. @@ -14,6 +14,7 @@ class OptionRegistry extends Registry<Option> { this.data['useDefaultValue'] = false; this.data['maxItems'] = null; this.data['maxLength'] = null; + this.data['defaultRandExpMax'] = 10; this.data['alwaysFakeOptionals'] = false; } }