diff --git a/lib/dynamic.js b/lib/dynamic.js index 2438da28..10c5f17e 100644 --- a/lib/dynamic.js +++ b/lib/dynamic.js @@ -44,8 +44,9 @@ Dynamic.converters = []; * @param {Function} converter */ -Dynamic.define = function(name, converter) { +Dynamic.define = function(name, converter, fromArgs) { converter.typeName = name; + converter.fromArgs = fromArgs !== false; this.converters.unshift(converter); }; @@ -56,8 +57,9 @@ Dynamic.define = function(name, converter) { * @returns {Boolean} */ -Dynamic.canConvert = function(type) { - return !!this.getConverter(type); +Dynamic.canConvert = function(type, fromArgs) { + var converter = this.getConverter(type); + return converter && converter.fromArgs === !!fromArgs; }; /** diff --git a/lib/http-context.js b/lib/http-context.js index 09c0ba32..dcc75702 100644 --- a/lib/http-context.js +++ b/lib/http-context.js @@ -210,7 +210,7 @@ HttpContext.prototype.buildArgs = function(method) { // For boolean and number types, convert certain strings to that type. // The user can also define new dynamic types. - if (Dynamic.canConvert(otype)) { + if (Dynamic.canConvert(otype, true)) { val = dynamic(val, otype, ctx); }