You are here

function And_Constraint::getValidationErrorMessage in Password Policy 5

Overrides Constraint::getValidationErrorMessage

1 call to And_Constraint::getValidationErrorMessage()
And_Constraint::getDescription in constraints/constraint_and.php

File

constraints/constraint_and.php, line 28

Class

And_Constraint

Code

function getValidationErrorMessage($plaintext_password = NULL, $user = NULL) {
  $reason = '<ul>';
  foreach ($this->constraints as $constraint) {
    $msg = NULL;

    // if we have a password to test, then indicate in the validation error
    // message, which constraints passed and which failed.
    if (isset($plaintext_password)) {
      if ($constraint
        ->validate($plaintext_password, $user)) {
        $msg = t('(PASS)') . ' ' . $constraint
          ->getValidationErrorMessage();
      }
      else {
        $msg = t('(FAIL)') . ' ' . $constraint
          ->getValidationErrorMessage();
      }
    }
    else {
      $msg = $constraint
        ->getValidationErrorMessage();
    }
    $reason .= "<li>{$msg}</li>";
  }
  return $reason . '</ul>';
}