You are here

function _pathauto_validate_numeric_element in Pathauto 6

Same name and namespace in other branches
  1. 6.2 pathauto.admin.inc \_pathauto_validate_numeric_element()
  2. 7 pathauto.admin.inc \_pathauto_validate_numeric_element()

Validate a form element that should have an numeric value.

1 string reference to '_pathauto_validate_numeric_element'
pathauto_admin_settings in ./pathauto.admin.inc
Form builder; Configure the Pathauto system.

File

./pathauto.admin.inc, line 352
Admin page callbacks for the Pathauto module.

Code

function _pathauto_validate_numeric_element($element, &$form_state) {
  $value = $element['#value'];
  if (!is_numeric($value)) {
    form_error($element, t('The field %name is not a valid number.', array(
      '%name' => $element['#title'],
    )));
  }
  elseif (isset($element['#max_value']) && $value > $element['#max_value']) {
    form_error($element, t('The field %name cannot be greater than @max.', array(
      '%name' => $element['#title'],
      '@max' => $element['#max_value'],
    )));
  }
  elseif (isset($element['#min_value']) && $value < $element['#min_value']) {
    form_error($element, t('The field %name cannot be less than @min.', array(
      '%name' => $element['#title'],
      '@min' => $element['#min_value'],
    )));
  }
}