You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
var _ = require('lodash'),
|
|
|
|
check = require('check-types');
|
|
|
|
|
|
|
|
// validate inputs
|
|
|
|
function _sanitize( raw, clean ){
|
|
|
|
// error & warning messages
|
|
|
|
var messages = { errors: [], warnings: [] };
|
|
|
|
|
|
|
|
Object.keys(raw).forEach(function(key) {
|
|
|
|
if (_.isArray(raw[key])) {
|
|
|
|
messages.errors.push('\'' + key + '\' parameter can only have one value');
|
|
|
|
delete raw[key];
|
|
|
|
} else if (_.isObject(raw[key])) {
|
|
|
|
messages.errors.push('\'' + key + '\' parameter must be a scalar');
|
|
|
|
delete raw[key];
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
// export function
|
|
|
|
module.exports = () => ({
|
|
|
|
sanitize: _sanitize
|
|
|
|
});
|