aproba
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -40,4 +40,9 @@ 'use strict' | ||
function invalidType (num, type, value) { | ||
return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' + type + ' but got ' + typeof value) | ||
function invalidType (num, expectedType, value) { | ||
var valueType | ||
Object.keys(types).forEach(function (typeCode) { | ||
if (types[typeCode][1](value)) valueType = types[typeCode][0] | ||
}) | ||
return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' + | ||
expectedType + ' but got ' + valueType) | ||
} | ||
@@ -44,0 +49,0 @@ |
{ | ||
"name": "aproba", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A rediculously light-weight argument validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,3 +26,3 @@ 'use strict' | ||
test('general', function (t) { | ||
t.plan(69) | ||
t.plan(70) | ||
var values = { | ||
@@ -82,2 +82,8 @@ 'A': [], | ||
}) | ||
try { | ||
validate('O', [[]]) | ||
t.fail('object != array') | ||
} catch (ex) { | ||
t.match(ex.message, /Expected object but got array/, 'When reporting non-objects, uses aproba types') | ||
} | ||
}) |
7520
135