packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js
function substringEvaluator(condition, userAttributes, logger) {
  var conditionName = condition.name;
  var userValue = userAttributes[condition.name];
  var userValueType = typeof userValue;
  var conditionValue = condition.value;

  if (typeof conditionValue !== 'string') {
    logger.log(LOG_LEVEL.WARNING, sprintf(LOG_MESSAGES.UNEXPECTED_CONDITION_VALUE, MODULE_NAME, JSON.stringify(condition)));
    return null;
  }

  if (userValue === null) {
    logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.UNEXPECTED_TYPE_NULL, MODULE_NAME, JSON.stringify(condition), conditionName));
    return null;
  }

  if (typeof userValue !== 'string') {
    logger.log(LOG_LEVEL.WARNING, sprintf(LOG_MESSAGES.UNEXPECTED_TYPE, MODULE_NAME, JSON.stringify(condition), userValueType, conditionName));
    return null;
  }

  return userValue.indexOf(conditionValue) !== -1;
}
function substringEvaluator(condition, userAttributes, logger) {
  var conditionName = condition.name;
  var userValue = userAttributes[condition.name];
  var userValueType = typeof userValue;
  var conditionValue = condition.value;

  if (typeof conditionValue !== 'string') {
    logger.log(LOG_LEVEL.WARNING, sprintf(LOG_MESSAGES.UNEXPECTED_CONDITION_VALUE, MODULE_NAME, JSON.stringify(condition)));
    return null;
  }

  if (userValue === null) {
    logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.UNEXPECTED_TYPE_NULL, MODULE_NAME, JSON.stringify(condition), conditionName));
    return null;
  }

  if (typeof userValue !== 'string') {
    logger.log(LOG_LEVEL.WARNING, sprintf(LOG_MESSAGES.UNEXPECTED_TYPE, MODULE_NAME, JSON.stringify(condition), userValueType, conditionName));
    return null;
  }

  return userValue.indexOf(conditionValue) !== -1;
}
function substringEvaluator ( condition , userAttributes , logger ) { var conditionName = condition . name ; var userValue = userAttributes [ condition . name ] ; var userValueType = typeof userValue ; var conditionValue = condition . value ; if ( typeof conditionValue !== 'string' ) { logger . log ( LOG_LEVEL . WARNING , sprintf ( LOG_MESSAGES . UNEXPECTED_CONDITION_VALUE , MODULE_NAME , JSON . stringify ( condition ) ) ) ; return null ; } if ( userValue === null ) { logger . log ( LOG_LEVEL . DEBUG , sprintf ( LOG_MESSAGES . UNEXPECTED_TYPE_NULL , MODULE_NAME , JSON . stringify ( condition ) , conditionName ) ) ; return null ; } if ( typeof userValue !== 'string' ) { logger . log ( LOG_LEVEL . WARNING , sprintf ( LOG_MESSAGES . UNEXPECTED_TYPE , MODULE_NAME , JSON . stringify ( condition ) , userValueType , conditionName ) ) ; return null ; } return userValue . indexOf ( conditionValue ) !== - 1 ; }
Evaluate the given substring match condition for the given user attributes
@param   {Object}    condition
@param   {Object}    userAttributes
@param   {Object}    logger
@returns {?Boolean}  true if the condition value is a substring of the user attribute value,
false if the condition value is not a substring of the user attribute value,
null if the condition value isn't a string or the user attribute value
isn't a string
Evaluate the given substring match condition for the given user attributes