t('Digit Placement'), 'description' => t('Minimum number of digits in the password to allow a digit in the first or last position in the password (e.g. 2abcdefg and abcdefg4 are unacceptable passwords, while 2qpcxrm3 and 99qpcxrm are allowed passwords when 2 is set here).')); } /** * Error message of the constraint. */ function password_policy_constraint_digit_placement_error($constraint) { return t('Password must have a minimum of %numChars %digits to place any digits at the start or end of the password.', array('%numChars' => $constraint, '%digits' => format_plural($constraint, t('digit'), t('digits')))); } /** * Password validation. */ function password_policy_constraint_digit_placement_validate($password, $constraint, $uid) { $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)$constraint) { return preg_match("/(^\d+)|(\d+$)/", $plaintext_password) != 1; } return TRUE; }