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.

$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_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

▾ 48 functions implement hook_validate()

aggregator_form_category_validate in modules/aggregator/aggregator.module
Validate aggregator_form_feed form submissions.
aggregator_form_feed_validate in modules/aggregator/aggregator.module
Validate aggregator_form_feed form submissions.
aggregator_page_list_validate in modules/aggregator/aggregator.module
block_admin_configure_validate in modules/block/block.module
block_box_form_validate in modules/block/block.module
comment_admin_overview_validate in modules/comment/comment.module
We can't execute any 'Update options' if no comments were selected.
comment_form_validate in modules/comment/comment.module
comment_validate in modules/comment/comment.module
contact_admin_edit_validate in modules/contact/contact.module
Validate the contact category edit page form submission.
contact_mail_page_validate in modules/contact/contact.module
Validate the site-wide contact page form submission.
date_validate in includes/form.inc
Validates the date type to stop dates like February 30, 2006.
example_element_validate in developer/examples/example_element.module
Our element's validation function.
fileupload_validate in developer/examples/fileupload.module
Implementation of hook_validate().
filter_admin_format_form_validate in modules/filter/filter.module
Validate filter format form submissions.
filter_form_validate in modules/filter/filter.module
forum_validate in modules/forum/forum.module
Implementation of hook_validate().
install_settings_form_validate in ./install.php
Form API validate for install_settings form.
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/node.module
node_configure_validate in modules/node/node.module
Form validate callback.
node_example_validate in developer/examples/node_example.module
Implementation of hook_validate().
node_form_validate in modules/node/node.module
node_search_validate in modules/node/node.module
Form API callback for the search form. Registered in node_form_alter().
node_type_form_validate in modules/node/content_types.inc
Implementation of hook_form_validate().
node_validate in modules/node/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/path.module
Verify that a new URL alias is valid
poll_validate in modules/poll/poll.module
Implementation of hook_validate().
profile_field_form_validate in modules/profile/profile.module
Validate profile_field_form submissions.
search_admin_settings_validate in modules/search/search.module
Validate callback.
search_form_validate in modules/search/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.
system_modules_uninstall_validate in modules/system/system.module
Validates the submitted uninstall form.
taxonomy_node_validate in modules/taxonomy/taxonomy.module
Make sure incoming vids are free tagging enabled.
throttle_admin_settings_validate in modules/throttle/throttle.module
upload_admin_settings_validate in modules/upload/upload.module
Form API callback to validate the upload settings form.
user_admin_access_check_validate in modules/user/user.module
user_admin_account_validate in modules/user/user.module
user_admin_role_validate in modules/user/user.module
user_edit_validate in modules/user/user.module
user_login_validate in modules/user/user.module
user_pass_validate in modules/user/user.module
user_register_validate in modules/user/user.module
_form_validate in includes/form.inc
Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.
_install_settings_form_validate in ./install.php
Helper function for install_settings_validate.
_locale_admin_manage_screen_validate in includes/locale.inc
_upload_validate in modules/upload/upload.module
_user_edit_validate in modules/user/user.module

File

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

Code

<?php
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.'));
    }
  }
}
?>

Comments

There is no detailed usage

Login or register to post comments