/**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @param  mixed $content
  * @return boolean
  * @throws \Zend_Validate_Exception If validation of $value is impossible
  */
 public function isValid($value, $context = array())
 {
     $this->_report = $this->_user->reportPasswordWeakness($value);
     foreach ($this->_report as &$report) {
         $report = ucfirst($report) . '.';
     }
     // \MUtil_Echo::track($value, $this->_report);
     return !(bool) $this->_report;
 }
 /**
  * Returns/sets an element showing the password rules
  *
  * @return \MUtil_Form_Element_Html
  */
 public function getReportRulesElement()
 {
     $element = $this->getElement($this->_reportRulesFieldName);
     if (!$element) {
         $info = $this->user->reportPasswordWeakness();
         // Show password info
         if ($info) {
             $element = new \MUtil_Form_Element_Html($this->_reportRulesFieldName);
             $element->setLabel($this->_('Password rules'));
             if (1 == count($info)) {
                 $element->div(sprintf($this->_('A password %s.'), reset($info)));
             } else {
                 foreach ($info as &$line) {
                     $line .= ';';
                 }
                 $line[strlen($line) - 1] = '.';
                 $element->div($this->_('A password:'))->ul($info);
             }
             $this->addElement($element);
         }
     }
     return $element;
 }
 /**
  * Check for password weakness.
  *
  * @param \Gems_User_User $user The user for e.g. name checks
  * @param string $password Or null when you want a report on all the rules for this password.
  * @return mixed String or array of strings containing warning messages
  */
 public function reportPasswordWeakness(\Gems_User_User $user, $password = null)
 {
     return $user->reportPasswordWeakness($password);
 }