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
700 B
25 lines
700 B
9 years ago
|
var check = require('check-types');
|
||
9 years ago
|
var geo_common = require ('./_geo_common');
|
||
8 years ago
|
|
||
9 years ago
|
var LAT_LON_IS_REQUIRED = false;
|
||
9 years ago
|
var RECT_IS_REQUIRED = false;
|
||
|
var CIRCLE_IS_REQUIRED = false;
|
||
9 years ago
|
|
||
|
// validate inputs, convert types and apply defaults
|
||
9 years ago
|
module.exports = function sanitize( raw, clean ){
|
||
9 years ago
|
|
||
9 years ago
|
// error & warning messages
|
||
|
var messages = { errors: [], warnings: [] };
|
||
9 years ago
|
|
||
9 years ago
|
try {
|
||
9 years ago
|
geo_common.sanitize_point( 'focus.point', clean, raw, LAT_LON_IS_REQUIRED );
|
||
|
geo_common.sanitize_rect( 'boundary.rect', clean, raw, RECT_IS_REQUIRED );
|
||
|
geo_common.sanitize_circle( 'boundary.circle', clean, raw, CIRCLE_IS_REQUIRED );
|
||
9 years ago
|
}
|
||
|
catch (err) {
|
||
9 years ago
|
messages.errors.push( err.message );
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
return messages;
|
||
9 years ago
|
};
|