Community Documentation

hook_validate

5 node.php hook_validate($node, &$form)
6 node.php hook_validate($node, &$form)
7 node.api.php hook_validate($node, $form, &$form_state)
8 node.api.php hook_validate($node, $form, &$form_state)

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.

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_submit() or hook_nodeapi($op='submit') 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

▾ 42 functions implement hook_validate()

aggregator_form_category_validate in modules/aggregator.module
Validate aggregator_form_feed form submissions.
aggregator_form_feed_validate in modules/aggregator.module
Validate aggregator_form_feed form submissions.
aggregator_page_list_validate in modules/aggregator.module
block_admin_configure_validate in modules/block.module
block_box_add_validate in modules/block.module
comment_admin_overview_validate in modules/comment.module
We can't execute any 'Update options' if no comments were selected.
comment_form_validate in modules/comment.module
comment_validate in modules/comment.module
contact_admin_edit_validate in modules/contact.module
Validate the contact category edit page form submission.
contact_mail_page_validate in modules/contact.module
Validate the site-wide contact page form submission.
date_validate in includes/form.inc
Validates the FAPI date type to stop dates like 30/Feb/2006
fileupload_validate in developer/examples/fileupload.module
Implementation of hook_validate().
filter_admin_format_form_validate in modules/filter.module
Validate filter format form submissions.
filter_form_validate in modules/filter.module
forum_validate in modules/forum.module
Implementation of hook_validate().
image_toolkit_validate in includes/image.inc
Validates toolkit selection.
locale_add_language_form_validate in includes/locale.inc
Validate the language addition form.
multipage_form_example_custom_validate in developer/examples/multipage_form_example.module
Validate our form.
node_admin_nodes_validate in modules/node.module
node_example_validate in developer/examples/node_example.module
Implementation of hook_validate().
node_form_validate in modules/node.module
node_search_validate in modules/node.module
Form API callback for the search form. Registered in node_form_alter().
node_validate in modules/node.module
Perform validation checks on the given node.
password_confirm_validate in includes/form.inc
Validate password_confirm element.
path_form_validate in modules/path.module
Verify that URL alias is valid.
poll_validate in modules/poll.module
Implementation of hook_validate().
profile_field_form_validate in modules/profile.module
Validate profile_field_form submissions.
search_form_validate in modules/search.module
As the search form collates keys from other modules hooked in via hook_form_alter, the validation takes place in _submit. search_form_validate() is used solely to set the 'processed_keys' form value for the basic search form.
search_settings_form_validate in modules/search.module
Implementation of hook_validate().
taxonomy_node_validate in modules/taxonomy.module
Make sure incoming vids are free tagging enabled.
upload_settings_form_validate in modules/upload.module
Form API callback to validate the upload settings form.
user_admin_access_check_validate in modules/user.module
user_admin_edit_role_validate in modules/user.module
user_admin_new_role_validate in modules/user.module
user_edit_validate in modules/user.module
user_login_validate in modules/user.module
user_pass_validate in modules/user.module
user_register_validate in modules/user.module
_form_validate in includes/form.inc
_throttle_validate in modules/throttle.module
_upload_validate in modules/upload.module
_user_edit_validate in modules/user.module

File

developer/hooks/node.php, line 307
These hooks are defined by node modules, modules that define a new kind of node.

Code

<?php
function hook_validate($node) {
  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.'));
    }
  }
}
?>
Login or register to post comments