I'm not aware of an existing module allowing the addition of custom validation, but it is fairly easy to implement this using the 'validate' action of hook_user()
:
function yourModule_user($op, &$edit, &$account, $category = NULL) {
// Are we in the validation phase of a new user registration?
if ('validate' == $op && 'user_register' == $edit['form_id'] && 'account' == $category) {
// Yes, do custom validation...
// NOTE: Just an example to validate by email.
// Check the other elements in $edit array (e.g. 'name') for more options
$mail_is_valid = yourModule_custom_mail_validation($edit['mail']);
// Is the mail address OK?
if (!$mail_is_valid) {
// No, set error on mail form field
form_set_error('mail', t('your custom error message'));
}
}
}
This would stop the registration process and redisplay the registration form with the error message on the mail field as long as yourModule_custom_mail_validation()
does not return TRUE.
If you want the validation to happen for existing users editing their account also, you could drop the
&& 'user_register' == $edit['form_id']
part from the first if clause - the code would then run for every user edit form submission, not just on registration.