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

▾ 63 functions implement hook_validate()

aggregator_categorize_items_validate in modules/aggregator/aggregator.pages.inc
Validate aggregator_categorize_items form submissions.
aggregator_form_category_validate in modules/aggregator/aggregator.admin.inc
Validate aggregator_form_feed form submissions.
aggregator_form_feed_validate in modules/aggregator/aggregator.admin.inc
Validate aggregator_form_feed form submissions.
block_add_block_form_validate in modules/block/block.admin.inc
block_admin_configure_validate in modules/block/block.admin.inc
book_admin_edit_validate in modules/book/book.admin.inc
Check that the book has not been changed while using the form.
book_admin_settings_validate in modules/book/book.admin.inc
Validate the book settings form.
color_scheme_form_validate in modules/color/color.module
Validation handler for color change form.
comment_admin_overview_validate in modules/comment/comment.admin.inc
Validate comment_admin_overview form submissions.
comment_form_validate in modules/comment/comment.module
Validate comment form submissions.
comment_validate in modules/comment/comment.module
Validate comment data.
contact_admin_edit_validate in modules/contact/contact.admin.inc
Validate the contact category edit page form submission.
contact_mail_page_validate in modules/contact/contact.pages.inc
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.
dblog_filter_form_validate in modules/dblog/dblog.admin.inc
Validate result from dblog administration filter form.
filter_admin_format_form_validate in modules/filter/filter.admin.inc
Validate filter format form submissions.
filter_form_validate in modules/filter/filter.module
Validation callback for filter elements in a form.
image_gd_settings_validate in includes/image.gd.inc
Validate the submitted GD settings.
install_configure_form_validate in ./install.php
Form API validate for the site configuration form.
install_settings_form_validate in ./install.php
Form API validate for install_settings form.
locale_languages_edit_form_validate in includes/locale.inc
Validate the language editing form. Reused for custom language addition too.
locale_languages_predefined_form_validate in includes/locale.inc
Validate the language addition form.
locale_translate_edit_form_validate in includes/locale.inc
Validate string editing form submissions.
menu_edit_item_validate in modules/menu/menu.admin.inc
Validate form values for a menu link being added or edited.
menu_edit_menu_validate in modules/menu/menu.admin.inc
Validates the human and machine-readable names when adding or editing a menu.
node_admin_nodes_validate in modules/node/node.admin.inc
Validate node_admin_nodes form submissions.
node_assign_owner_action_validate in modules/node/node.module
node_form_validate in modules/node/node.pages.inc
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
Validates the content type submission form generated by node_type_form().
node_validate in modules/node/node.module
Perform validation checks on the given node.
openid_login_validate in modules/openid/openid.module
Login form _validate hook
openid_user_add_validate in modules/openid/openid.pages.inc
password_confirm_validate in includes/form.inc
Validate password_confirm element.
path_admin_form_validate in modules/path/path.admin.inc
Verify that a new URL alias is valid
poll_validate in modules/poll/poll.module
Implementation of hook_validate().
poll_view_voting_validate in modules/poll/poll.module
Validation function for processing votes
profile_field_form_validate in modules/profile/profile.admin.inc
Validate profile_field_form submissions.
search_admin_settings_validate in modules/search/search.admin.inc
Validate callback.
search_form_validate in modules/search/search.pages.inc
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_actions_configure_validate in modules/system/system.module
Validate system_actions_configure form submissions.
system_modules_uninstall_validate in modules/system/system.admin.inc
Validates the submitted uninstall form.
system_send_email_action_validate in modules/system/system.module
Validate system_send_email_action form submissions.
system_site_information_settings_validate in modules/system/system.admin.inc
Validate the submitted site-information form.
taxonomy_form_term_validate in modules/taxonomy/taxonomy.admin.inc
Validation handler for the term edit form. Ensure numeric weight values.
taxonomy_node_validate in modules/taxonomy/taxonomy.module
Make sure incoming vids are free tagging enabled.
throttle_admin_settings_validate in modules/throttle/throttle.admin.inc
trigger_assign_form_validate in modules/trigger/trigger.admin.inc
Validation function for trigger_assign_form().
update_settings_validate in modules/update/update.settings.inc
Validation callback for the settings form.
upload_admin_settings_validate in modules/upload/upload.admin.inc
Form API callback to validate the upload settings form.
user_admin_access_check_validate in modules/user/user.admin.inc
user_admin_account_validate in modules/user/user.admin.inc
user_admin_role_validate in modules/user/user.admin.inc
user_edit_validate in modules/user/user.pages.inc
user_login_authenticate_validate in modules/user/user.module
A validate handler on the login form. Check supplied username/password against local users table. If successful, sets the global $user object.
user_login_final_validate in modules/user/user.module
A validate handler on the login form. Should be the last validator. Sets an error if user has not been authenticated yet.
user_login_name_validate in modules/user/user.module
A FAPI validate handler. Sets an error if supplied username has been blocked or denied access.
user_pass_validate in modules/user/user.pages.inc
user_profile_form_validate in modules/user/user.pages.inc
Validation function for the user account and profile editing form.
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.
_user_edit_validate in modules/user/user.module

File

developer/hooks/node.php, line 371
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.'));
    }
  }
}
?>
Login or register to post comments