Update isNumeric function with Object type check.

Fix false positive of isNumeric function in order to allow
where query on nested object in graphql.
This commit is contained in:
Anthony Guimard 2018-09-15 23:16:20 -04:00
parent 6a24021a2a
commit 73fb19ca0f

View File

@ -12,7 +12,7 @@ const _ = require('lodash');
// Following this discussion https://stackoverflow.com/questions/18082/validate-decimal-numbers-in-javascript-isnumeric this function is the best implem to determine if a value is a valid number candidate
const isNumeric = (value) => {
return !isNaN(parseFloat(value)) && isFinite(value);
return !_.isObject(value) && !isNaN(parseFloat(value)) && isFinite(value);
};
/* eslint-disable prefer-template */
@ -466,7 +466,7 @@ module.exports = {
// Remove the filter keyword at the end
let splitKey = key.split('_').slice(0,-1);
splitKey = splitKey.join('_');
if (modelAttributes[splitKey]) {
fieldType = modelAttributes[splitKey]['type'];
}