You are here

function field_test_field_validate in Drupal 7

Implements hook_field_validate().

Possible error codes:

  • 'field_test_invalid': The value is invalid.

File

modules/field/tests/field_test.field.inc, line 110
Defines a field type and its formatters and widgets.

Code

function field_test_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  $args = func_get_args();
  field_test_memorize(__FUNCTION__, $args);
  foreach ($items as $delta => $item) {
    if ($item['value'] == -1) {
      $errors[$field['field_name']][$langcode][$delta][] = array(
        'error' => 'field_test_invalid',
        'message' => t('%name does not accept the value -1.', array(
          '%name' => $instance['label'],
        )),
      );
    }
  }
}