hook_node_validate
function hook_node_validate
hook_node_validate($node, $form, &$form_state)
Perform node validation before a node is created or updated.
This hook is invoked from node_validate(), after a user has has finished editing the node and is previewing or submitting it. It is invoked at the end of all the standard validation steps, and after the type-specific hook_validate() is invoked.
To indicate a validation error, use form_set_error().
Note: Changes made to the $node object within your hook implementation will have no effect. The preferred method to change a node's content is to use hook_node_presave() instead. If it is really necessary to change the node at the validate stage, you can use form_set_value().
Parameters
$node: The node being validated.
$form: The form being used to edit the node.
$form_state: The form state array.
Related topics
File
- modules/node/node.api.php, line 771
- Hooks provided by the Node module.
Code
function hook_node_validate($node, $form, &$form_state) { 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.')); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_node_validate/7.x