1 field_test.field.inc field_test_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)

Implements hook_field_validate().

Possible error codes:

  • 'field_test_invalid': The value is invalid.

File

core/modules/field/tests/field_test/field_test.field.inc, line 109
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'])),
      );
    }
  }
}