function hook_validate
7.x node.api.php | hook_validate($node, $form, & |
6.x node.php | 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. Errors should be set with form_set_error().
Parameters
$node: The node to be validated.
$form: The node edit form array.
Return value
None.
To validate nodes of all types (not just nodes of the type(s) defined by this module), use hook_nodeapi() instead.
Changes made to the $node object within a hook_validate() function will have no effect. The preferred method to change a node's content is to use hook_nodeapi($op='presave') instead. If it is really necessary to change the node at the validate stage, you can use function form_set_value().
For a detailed usage example, see node_example.module.
Related topics
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- aggregator_categorize_items_validate in drupal-6.x/
modules/ aggregator/ aggregator.pages.inc - Validate aggregator_categorize_items form submissions.
- aggregator_form_category_validate in drupal-6.x/
modules/ aggregator/ aggregator.admin.inc - Validate aggregator_form_feed form submissions.
- aggregator_form_feed_validate in drupal-6.x/
modules/ aggregator/ aggregator.admin.inc - Validate aggregator_form_feed form submissions.
- block_add_block_form_validate in drupal-6.x/
modules/ block/ block.admin.inc - block_admin_configure_validate in drupal-6.x/
modules/ block/ block.admin.inc
- node_validate in drupal-6.x/
modules/ node/ node.module - Perform validation checks on the given node.
- user_edit_validate in drupal-6.x/
modules/ user/ user.pages.inc - user_profile_form_validate in drupal-6.x/
modules/ user/ user.pages.inc - Validation function for the user account and profile editing form.
- user_register_validate in drupal-6.x/
modules/ user/ user.module
File
- documentation-6.x/
developer/ hooks/ node.php, line 371 - These hooks are defined by node modules, modules that define a new kind of node.
Code
function hook_validate($node, &$form) {
if (isset($node->end) && isset($node->start)) {
if ($node->start > $node->end) {
form_set_error('time', t('An event may not end before it starts.'));
}
}
}