? sites/d7-head.com
? sites/all/libraries
Index: modules/comment/comment.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.api.php,v
retrieving revision 1.18
diff -u -p -r1.18 comment.api.php
--- modules/comment/comment.api.php	23 Oct 2010 15:30:34 -0000	1.18
+++ modules/comment/comment.api.php	18 Nov 2010 22:26:59 -0000
@@ -12,6 +12,19 @@
  */
 
 /**
+ * The user has just finished editing the comment and is trying to preview or
+ * submit it. This hook can be used to check or even modify the comment. Errors
+ * should be set with form_set_error().
+ * 
+ * @param $edit
+ *   an array of form values submitted by the user
+ */
+function hook_comment_validate(&$edit) {
+  // validate the comment body
+  validate_comment($edit['comment_body']['und'][0]['value']);
+}
+
+/**
  * The comment passed validation and is about to be saved.
  *
  * Modules may make changes to the comment before it is saved to the database.
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.917
diff -u -p -r1.917 comment.module
--- modules/comment/comment.module	15 Nov 2010 00:49:46 -0000	1.917
+++ modules/comment/comment.module	18 Nov 2010 22:27:00 -0000
@@ -2112,6 +2112,12 @@ function comment_form_validate($form, &$
   if ($form_state['values']['homepage'] && !valid_url($form_state['values']['homepage'], TRUE)) {
     form_set_error('homepage', t('The URL of your homepage is not valid. Remember that it must be fully qualified, i.e. of the form <code>http://example.com/directory</code>.'));
   }
+  
+  // invokde hook_comment_validate
+  foreach (module_implements('comment_validate') as $name) {
+  	$function = $name . '_comment_validate';
+    $function($form_state['values']);
+  }
 }
 
 /**
