function preProcessor(q, field, document, userId, logger) {
    //logger.info("------TESTING DATE PREPROCESSOR");
    let moment = require('moment');

    if (document[field.name]) {
        if(typeof document[field.name] === 'object'){
            if(document[field.name].approveDate){
                let date = moment(
                    document[field.name].approveDate,
                    ["DD/MM/YYYY hh:mm a", "DD/MM/YYYY", "hh:mm a","DD/MM/YY","DD/MM/YY hh:mm a","DD/MM",moment.ISO_8601],
                    true
                );
                if (date.isValid()) {
                    document[field.name].approveDate = date.toDate();
                    return document;
                } else {
                    let errMsg = field.componentName + " field named " + field.name +
                    " has invalid value. approveDate should be a date object.";
                    logger.error("Preprocessing Failure : " + errMsg);
                    throw errMsg;
                }
            }
        }else{
            let errMsg = field.componentName + " field named " + field.name + " has invalid value. It should be an object.";
            logger.error("Approve Preprocessing Failure : " + errMsg);
            throw errMsg;
        }
    } else {
        return document;
    }
}
module.exports = preProcessor;
