I'm getting Parse error: syntax error, unexpected T_VARIABLE, expecting ')' on the line commented below. Can't for the life of me figure out why it's throwing this error.
public $validate = array(
'password1' => array(
'rule1' => array('rule' => 'alphaNumeric', 'message' => 'Your password should only contain alphanumeric characters.'),
'rule2' => array('rule' => '/\d/', 'message' => 'Your password must contain at least one numeric character.'),
'rule3' => array('rule' => '/^(?=.*?[A-Z])(?=.*?[a-z])/', 'message' => 'Your password must contain at least one uppercase and one lowercase letter.'),
'rule4' => array('rule' => array('minLength', 8), 'message' => 'Your password must be at least 8 characters long.'),
),
'password2' => array(
// ERROR ON LINE BELOW
'rule' => array('_passwordsMatch', $this->data['PasswordReset']['password2']),
'message' => 'The passwords you entered do not match.'
)
);
/**
* Custom validation method to check that the entered passwords match
*
* @param string $password1
* @param string $password2
* @return bool
*/
protected function _passwordsMatch($password1, $password2) {
return ($password1 === $password2);
}
As you can see I'm trying to make a custom validation rule to check the two passwords coming from the user's submitted form. Related question would be is this the wrong way to be trying to pass the other field value to the custom rule?