hook_validate

Versions
4.6
hook_validate(&$node)
4.7
hook_validate($node)
5 – 7
hook_validate($node, &$form)

Verify a node editing form.

This is a hook used by node modules. It is called to allow the module to verify that the node is in a format valid to post to the site. It can also be used to make changes to the node before submission, such as node-type-specific formatting. Errors should be set with form_set_error().

To validate nodes of all types (not just nodes of the type(s) defined by this module), use hook_nodeapi() instead.

For a detailed usage example, see node_example.module.

Parameters

&$node The node to be validated.

Return value

None.

Related topics

Code

developer/hooks/node.php, line 250

<?php
function hook_validate(&$node) {
  if ($node) {
    if ($node->end && $node->start) {
      if ($node->start > $node->end) {
        form_set_error('time', t('An event may not end before it starts.'));
      }
    }
  }
}
?>
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.