mirror of https://github.com/pelias/api.git
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.
25 lines
591 B
25 lines
591 B
|
|
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;
|
|
|