constraint_username.php in Password Policy 5        
                          
                  
                        
  
  
  
  
File
  constraints/constraint_username.php
  
    View source  
  <?php
include_once 'constraint.php';
class Username_Constraint extends Constraint {
  function validate($plaintext_password, $user = NULL) {
    return drupal_strtolower($user->name) != drupal_strtolower($plaintext_password);
  }
  function getDescription() {
    return t('Password must differ from the username. Put any positive number to enforce this policy.');
  }
  function getValidationErrorMessage() {
    return t('Password must differ from the username.');
  }
  function _charIsValid($character) {
    return TRUE;
  }
}