whitelister
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -0,1 +1,3 @@ | ||
const { isFunc } = require('./helpers'); | ||
module.exports.BaseError = class extends Error { | ||
@@ -7,2 +9,8 @@ constructor(msg = '') { | ||
} | ||
toJSON() { | ||
return { | ||
message: this.message, | ||
}; | ||
} | ||
}; | ||
@@ -51,5 +59,10 @@ | ||
this.addToMessage(err.message); | ||
} else { | ||
} else if (isFunc(err.toJSON)) { | ||
this.errors.push(err.toJSON()); | ||
this.addToMessage(err.toString()); | ||
} else { | ||
this.errors.push({ | ||
message: err.toString(), | ||
}); | ||
this.addToMessage(err.message || err.toString()); | ||
} | ||
@@ -56,0 +69,0 @@ }); |
@@ -95,3 +95,3 @@ const { ArgumentError, FieldError, WhitelistError } = require('./errors'); | ||
filteredParams[name] = val; | ||
} else if (has.call(params, name)) { | ||
} else if (has.call(params, name) && isDefined(params[name])) { | ||
val = params[name]; | ||
@@ -98,0 +98,0 @@ if (val === null && (rule.allowNull || rule.type === 'null')) { |
{ | ||
"name": "whitelister", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Simple, basic filtering and validation tool for Node.js.", | ||
@@ -5,0 +5,0 @@ "main": "whitelister.js", |
14368
335