You are here

function _field_validation_numeric_check_data in Field Validation 7

Process the numeric value validation range that was provided in the numeric validator options

1 call to _field_validation_numeric_check_data()
field_validation_field_validation_validate in ./field_validation.validators.inc
Implements hook_field_validation_validate().

File

./field_validation.validators.inc, line 741
Provides validation functionality and hooks

Code

function _field_validation_numeric_check_data($data) {
  $range = array(
    'min' => NULL,
    'max' => NULL,
  );

  // if no value was specified, don't validate
  if ($data == '') {
    return $range;
  }

  // If only one numeric value was specified, this is the min value
  if (is_numeric($data)) {
    $range['min'] = (int) $data;
  }
  if (strpos($data, '|') !== FALSE) {
    list($min, $max) = explode('|', $data);
    if ($min != '' && is_numeric($min)) {
      $range['min'] = (int) $min;
    }
    if ($max != '' && is_numeric($max)) {
      $range['max'] = (int) $max;
    }
  }
  return $range;
}