function preProcessor(q, field, document, userId, logger) { 
    let deferred = q.defer();
    
    if(document[field.name] != null) {
        if (typeof document[field.name]  === 'string') {
            // Commented this code because this is commented in the core change(13630: do not delete null/empty field in preprocessor);
            //if (document[field.name].length === 0) {
            //    delete document[field.name];
            //}
            deferred.resolve(document);
        }else{
            let errMsg = field.componentName + " field named " + field.name + " has invalid value";
            deferred.reject(errMsg);
        }
    }else{
        deferred.resolve(document);
    }

    return deferred.promise;
}
module.exports = preProcessor;
