function field_test_field_validate

Implements hook_field_validate().

Possible error codes:

  • 'field_test_invalid': The value is invalid.

File

modules/field/tests/field_test.field.inc, line 110

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'],
                )),
            );
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.