function validate($value)
 {
     if ($this->field->Form && $this->field->Form->Record) {
         $result = $this->validator->validate($value, $this->field->Form->Record);
         return $result->valid();
     }
     return true;
 }
Esempio n. 2
0
 public function testValidateMinScore()
 {
     $v = new PasswordValidator();
     $v->characterStrength(3, array("lowercase", "uppercase", "digits", "punctuation"));
     $r = $v->validate('aA', new Member());
     $this->assertFalse($r->valid(), 'Passing too few tests');
     $r = $v->validate('aA1', new Member());
     $this->assertTrue($r->valid(), 'Passing enough tests');
 }
 /**
  * Validates that the information we've just received from the blog settings
  * form is valid... We have to be really sure about this one!!!
  */
 function validate()
 {
     // if all correct, we can proceed
     $this->_userPassword = trim($this->_request->getValue("userSettingsPassword"));
     $this->_userConfirmPassword = trim($this->_request->getValue("confirmPassword"));
     $valid = parent::validate();
     // check that the password is correct and confirm it
     if ($this->_userPassword != "") {
         $passwordVal = new PasswordValidator();
         if (!$passwordVal->validate($this->_userPassword)) {
             $this->_form->setFieldValidationStatus("userSettingsPassword", false);
             $this->setCommonData(true);
             return false;
         }
         if ($this->_userPassword != $this->_userConfirmPassword) {
             $this->_form->setFieldValidationStatus("confirmPassword", false);
             $this->setCommonData(true);
             return false;
         }
     }
     return $valid;
 }