Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.isFilterValid = function(input) {
if (isEmpty(input)) {
return DEFAULT_FILTER;
}
try {
const parsed = parseFilter(input);
// is it a valid MongoDB query according to the language?
return queryLanguage.accepts(EJSON.stringify(parsed)) ? parsed : false;
} catch (e) {
debug('Filter "%s" is invalid', input, e);
return false;
}
};