function processCondition(field,conditionString,flatPayload){
    let split = conditionString.split(":",2);
    let condNum, payloadNum;
    try{
        switch(split[0]){
            case "map":
                var map = {};
                if(flatPayload[field]  === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                map[split[1]] = flatPayload[field] || '';
                return {map};
            case "lt":  
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                    
                condNum = parseFloat(split[1]);
                payloadNum = parseFloat(flatPayload[field]);
                var mt = payloadNum < condNum;
                if(!mt)
                    logEvent('','',"Match template failure: field " + field + " did not match lt condition.");
                return mt;
            case "gt":  
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                condNum = parseFloat(split[1]);
                payloadNum = parseFloat(flatPayload[field]);
                var mt = payloadNum > condNum;
                if(!mt)
                    logEvent('','',"Match template failure: field " + field + " did not match gt condition.");
                return mt;

            case "any":
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                return flatPayload[field] !== undefined;
            case "regex":
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                var reg = new RegExp(split[1]);
                var mt = flatPayload[field].match(reg) !== null;
                if(!mt)
                    logEvent('','',"Match template failure: field " + field + " did not match regex.");
                return mt;
            default:
                return {};
        }
    }catch(e){
        console.log(e);
        debug(e);
        return false;
    }
}
/**
 * Given a condition string, process this condition.
 * @param {string} field Flattened field name (e.g. "params.person.firstName")
 * @param {string} conditionString The condition string (e.g. map:firstName)
 * @param {object} flatPayload  Flattened payload
 * @return Returns either an object that contains new options for the template, OR false if the condition is considered failed. ONLY false is considered a failure- {} or null is a pass!
 */
Given a condition string, process this condition.
@param {string} field Flattened field name
@param {string} conditionString The condition string
@param {object} flatPayload  Flattened payload
@return Returns either an object that contains new options for the template, OR false if the condition is considered failed. ONLY false is considered a failure- {} or null is a pass!
Given a condition string process this condition . @param { string } field Flattened field name @param { string } conditionString The condition string @param { object } flatPayload Flattened payload @return Returns either an object that contains new options for the template OR false if the condition is considered failed . ONLY false is considered a failure - {} or null is a pass!
function processCondition(field,conditionString,flatPayload){
    let split = conditionString.split(":",2);
    let condNum, payloadNum;
    try{
        switch(split[0]){
            case "map":
                var map = {};
                if(flatPayload[field]  === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                map[split[1]] = flatPayload[field] || '';
                return {map};
            case "lt":  
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                condNum = parseFloat(split[1]);
                payloadNum = parseFloat(flatPayload[field]);
                var mt = payloadNum < condNum;
                if(!mt)
                    logEvent('','',"Match template failure: field " + field + " did not match lt condition.");
                return mt;
            case "gt":  
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                condNum = parseFloat(split[1]);
                payloadNum = parseFloat(flatPayload[field]);
                var mt = payloadNum > condNum;
                if(!mt)
                    logEvent('','',"Match template failure: field " + field + " did not match gt condition.");
                return mt;
            case "any":
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                return flatPayload[field] !== undefined;
            case "regex":
                if(flatPayload[field] === undefined){
                    logEvent('','',"Match template failure: field " + field + " missing.");
                    return false;
                }
                var reg = new RegExp(split[1]);
                var mt = flatPayload[field].match(reg) !== null;
                if(!mt)
                    logEvent('','',"Match template failure: field " + field + " did not match regex.");
                return mt;
            default:
                return {};
        }
    }catch(e){
        console.log(e);
        debug(e);
        return false;
    }
}
function processCondition ( field , conditionString , flatPayload ) { let split = conditionString . split ( ":" , 2 ) ; let condNum , payloadNum ; try { switch ( split [ 0 ] ) { case "map" : var map = { } ; if ( flatPayload [ field ] === undefined ) { logEvent ( '' , '' , "Match template failure: field " + field + " missing." ) ; return false ; } map [ split [ 1 ] ] = flatPayload [ field ] || '' ; return { map } ; case "lt" : if ( flatPayload [ field ] === undefined ) { logEvent ( '' , '' , "Match template failure: field " + field + " missing." ) ; return false ; } condNum = parseFloat ( split [ 1 ] ) ; payloadNum = parseFloat ( flatPayload [ field ] ) ; var mt = payloadNum < condNum ; if ( ! mt ) logEvent ( '' , '' , "Match template failure: field " + field + " did not match lt condition." ) ; return mt ; case "gt" : if ( flatPayload [ field ] === undefined ) { logEvent ( '' , '' , "Match template failure: field " + field + " missing." ) ; return false ; } condNum = parseFloat ( split [ 1 ] ) ; payloadNum = parseFloat ( flatPayload [ field ] ) ; var mt = payloadNum > condNum ; if ( ! mt ) logEvent ( '' , '' , "Match template failure: field " + field + " did not match gt condition." ) ; return mt ; case "any" : if ( flatPayload [ field ] === undefined ) { logEvent ( '' , '' , "Match template failure: field " + field + " missing." ) ; return false ; } return flatPayload [ field ] !== undefined ; case "regex" : if ( flatPayload [ field ] === undefined ) { logEvent ( '' , '' , "Match template failure: field " + field + " missing." ) ; return false ; } var reg = new RegExp ( split [ 1 ] ) ; var mt = flatPayload [ field ] . match ( reg ) !== null ; if ( ! mt ) logEvent ( '' , '' , "Match template failure: field " + field + " did not match regex." ) ; return mt ; default : return { } ; } } catch ( e ) { console . log ( e ) ; debug ( e ) ; return false ; } }
Given a condition string, process this condition.
Given a condition string process this condition .