On this page
function number_field_validate
number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)
  Implements hook_field_validate().
Possible error codes:
- 'number_min': The value is less than the allowed minimum value.
 - 'number_max': The value is greater than the allowed maximum value.
 
File
- modules/field/modules/number/number.module, line 135
 - Defines numeric field types.
 
Code
function number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  foreach ($items as $delta => $item) {
    if ($item['value'] != '') {
      if (is_numeric($instance['settings']['min']) && $item['value'] < $instance['settings']['min']) {
        $errors[$field['field_name']][$langcode][$delta][] = array(
          'error' => 'number_min',
          'message' => t('%name: the value may be no less than %min.', array('%name' => $instance['label'], '%min' => $instance['settings']['min'])),
        );
      }
      if (is_numeric($instance['settings']['max']) && $item['value'] > $instance['settings']['max']) {
        $errors[$field['field_name']][$langcode][$delta][] = array(
          'error' => 'number_max',
          'message' => t('%name: the value may be no greater than %max.', array('%name' => $instance['label'], '%max' => $instance['settings']['max'])),
        );
      }
    }
  }
}
  © 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
 https://api.drupal.org/api/drupal/modules!field!modules!number!number.module/function/number_field_validate/7.x