Same name and namespace in other branches
- 4.7.x developer/hooks/node.php \hook_validate()
- 5.x developer/hooks/node.php \hook_validate()
- 6.x developer/hooks/node.php \hook_validate()
- 7.x modules/node/node.api.php \hook_validate()
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().
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.
For a detailed usage example, see node_example.module.
Related topics
8 functions implement hook_validate()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- book_validate in modules/
book.module - Implementation of hook_validate().
- fileupload_validate in developer/
examples/ fileupload.module - forum_validate in modules/
forum.module - Implementation of hook_validate().
- menu_edit_item_validate in modules/
menu.module - Confirm that an edited menu item has fields properly filled in.
- node_example_validate in developer/
examples/ node_example.module - Implementation of hook_validate().
3 invocations of hook_validate()
- user_admin_create in modules/
user.module - user_edit in modules/
user.module - user_register in modules/
user.module
File
- developer/
hooks/ node.php, line 250 - These hooks are defined by node modules, modules that define a new kind of node.
Code
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.'));
}
}
}
}