field_attach_validate

Versions
7
field_attach_validate($obj_type, $object)

Perform field validation against the field data in an object.

This function does not perform field widget validation on form submissions. It is intended to be called during API save operations. Use field_attach_form_validate() to validate form submissions.

@throws FieldValidationException If validation errors are found, a FieldValidationException is thrown. The 'errors' property contains the array of errors, keyed by field name, language and delta.

Parameters

$obj_type The type of $object; e.g. 'node' or 'user'.

$object The object with fields to validate.

Related topics

Code

modules/field/field.attach.inc, line 692

<?php
function field_attach_validate($obj_type, $object) {
  $errors = array();
  // Check generic, field-type-agnostic errors first.
  _field_invoke_default('validate', $obj_type, $object, $errors);
  // Check field-type specific errors.
  _field_invoke('validate', $obj_type, $object, $errors);

  // Let other modules validate the object.
  // Avoid module_invoke_all() to let $errors be taken by reference.
  foreach (module_implements('field_attach_validate') as $module) {
    $function = $module . '_field_attach_validate';
    $function($obj_type, $object, $errors);
  }

  if ($errors) {
    throw new FieldValidationException($errors);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.