express-request-checker
Advanced tools
Comparing version 0.0.3 to 0.0.5
26
index.js
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var sendError = function(res, scopeOption, paramName, errorMessage) { | ||
@@ -17,3 +15,3 @@ var response = '[ParamsPicker]'; | ||
if (options.scope === 'query' || options.scope === 'body') { | ||
scopeOption = options.scope; | ||
scopeOption = options.scope; | ||
} | ||
@@ -27,4 +25,4 @@ } | ||
var paramsOption = null | ||
if (typeof options.params === 'object') { | ||
var paramsOption = {}; | ||
if (typeof options.params !== 'undefined' && options.params !== null) { | ||
paramsOption = options.params; | ||
@@ -37,3 +35,3 @@ } | ||
if (typeof option.isOptional === 'boolean') { | ||
isOptional = option.isOptional; | ||
isOptional = option.isOptional; | ||
} | ||
@@ -50,4 +48,4 @@ | ||
else { | ||
sendError(res, scopeOption, paramName, 'Missing parameter.'); | ||
return; | ||
sendError(res, scopeOption, paramName, 'Missing parameter.'); | ||
return; | ||
} | ||
@@ -58,6 +56,6 @@ } | ||
if (typeof option.matchRegExp !== 'undefined' && option.matchRegExp !== null) { | ||
if (!option.matchRegExp.test(input)) { | ||
sendError(res, scopeOption, paramName, 'Invalid value, `' + input + '` not match `' + option.matchRegExp + '`'); | ||
return; | ||
} | ||
if (!option.matchRegExp.test(input)) { | ||
sendError(res, scopeOption, paramName, 'Invalid value, `' + input + '` not match `' + option.matchRegExp + '`'); | ||
return; | ||
} | ||
} | ||
@@ -70,4 +68,4 @@ } | ||
if (typeof paramsOption[reqParamName] === 'undefined') { | ||
sendError(res, scopeOption, reqParamName, 'Unexpected parameter'); | ||
return; | ||
sendError(res, scopeOption, reqParamName, 'Unexpected parameter'); | ||
return; | ||
} | ||
@@ -74,0 +72,0 @@ } |
{ | ||
"name": "express-request-checker", | ||
"version": "0.0.3", | ||
"version": "0.0.5", | ||
"description": "Express request checker extension.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
5541
64