You are here

function field_test_field_validate in SimpleTest 7

Implement hook_field_validate().

Possible error codes:

  • 'field_test_invalid': The value is invalid.

File

tests/field_test.module, line 427

Code

function field_test_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {
  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'],
        )),
      );
    }
  }
}