function _webform_validation_update_range_syntax in Webform Validation 6
Same name and namespace in other branches
- 7 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 - Implementation of hook_update_X().
File
- ./
webform_validation.install, line 121 - 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 (substr($range, 0, 2) == "0-" || substr($range, 0, 3) == "0 -") {
$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;
}