function Digit_Placement_Constraint::validate in Password Policy 5
Overrides Character_Constraint::validate
File
- constraints/
constraint_digit_placement.php, line 15
Class
Code
function validate($plaintext_password, $user = NULL) {
$number_of_digits = 0;
for ($i = 0; $i < 10; $i++) {
$number_of_digits += substr_count($plaintext_password, "{$i}");
// help string count by sending it a string instead of an int
}
if ($number_of_digits < (int) $this->minimumConstraintValue) {
return preg_match("/(^\\d+)|(\\d+\$)/", $plaintext_password) != 1;
}
return TRUE;
}