function password_policy_constraint_punctuation_validate in Password Policy 7
Same name and namespace in other branches
- 6 constraints/constraint_punctuation.inc \password_policy_constraint_punctuation_validate()
Password validation.
1 call to password_policy_constraint_punctuation_validate()
- PasswordPolicyTestCase::testPunctuationConstraint in tests/
password_policy.test - Test punctuation constraint.
File
- constraints/
constraint_punctuation.inc, line 29 - Password policy constraint callbacks.
Code
function password_policy_constraint_punctuation_validate($password, $constraint, $account) {
$matches = array();
$punctuation_characters = '`~!@#$%^&*()_+=-|}{"?:><,./;\'\\[]';
$punctuation_pattern = '/[' . preg_quote($punctuation_characters, '/') . ']/';
$count = preg_match_all($punctuation_pattern, $password, $matches);
return $count >= $constraint;
}