Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand All @@ -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;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/http-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down