You are here

function _webform_validation_update_range_syntax in Webform Validation 7

Same name and namespace in other branches
  1. 6 webform_validation.install \_webform_validation_update_range_syntax()

Helper function: update numeric validator range to new syntax.

1 call to _webform_validation_update_range_syntax()
webform_validation_update_1 in ./webform_validation.install
Update numeric validator range to new syntax.

File

./webform_validation.install, line 128
Webform_validation installation file.

Code

function _webform_validation_update_range_syntax($range) {

  // No longer use "0" as indicator for no validation. This should be an empty
  // string.
  if ($range === "0") {
    return "";
  }

  // Replace "0-VAL" with "|VAL" as indicator for less than or equal to.
  if (preg_match('/^0 ?-/', $range)) {
    $range_arr = explode('-', $range);
    $range_end = $range_arr[1];
    return "|" . trim($range_end);
  }

  // Replace "-" as separator between range values in favor of "|".
  $range = str_replace("-", "|", $range);
  return $range;
}