Redaxscript\Validator\Password::validate PHP Method

validate() public method

validate the password
Since: 2.6.0
public validate ( string $password = null, string $hash = null ) : boolean
$password string plain password
$hash string hashed password
return boolean
    public function validate($password = null, $hash = null)
    {
        $output = ValidatorInterface::FAILED;
        $passwordHash = new Hash(Config::getInstance());
        /* validate password */
        if ($password && $passwordHash->validate($password, $hash)) {
            $output = ValidatorInterface::PASSED;
        }
        return $output;
    }

Usage Example

Example #1
0
 /**
  * testPassword
  *
  * @since 2.6.0
  *
  * @param string $password
  * @param array $hashArray
  * @param integer $expect
  *
  * @dataProvider providerPassword
  */
 public function testPassword($password = null, $hashArray = [], $expect = null)
 {
     /* setup */
     $validator = new Validator\Password();
     /* actual */
     $actual = $validator->validate($password, function_exists('password_verify') ? $hashArray[0] : $hashArray[1]);
     /* compare */
     $this->assertEquals($expect, $actual);
 }
All Usage Examples Of Redaxscript\Validator\Password::validate
Password