function preProcessor(q, field, document, userId, logger) {
    if (document[field.name]) {
        let saveValue = document[field.name];
        let errMsg = field.componentName + " field named " + field.name +
            " has invalid value \"" + saveValue + "\"";
        let typeOfField = typeof document[field.name];

        if (typeOfField === "number") {
            return document;
        } else {
            try {
                let numeric = parseFloat(document[field.name]);
                if (isNaN(numeric)) {
                    logger.error("Preprocessing Failure : " + errMsg);
                    return null;
                } else {
                    document[field.name] = numeric;
                    return document;
                }
            } catch (err) {
                logger.error("Preprocessing Failure : " + errMsg);
                return null;
            }

        }
    } else {
        return document;
    }
}

module.exports = preProcessor;
