digit.rb 419 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class PasswordPolicy
  3. class Digit < PasswordPolicy::Backend
  4. NEED_DIGIT_REGEXP = %r{\d}
  5. def valid?
  6. @password.match? NEED_DIGIT_REGEXP
  7. end
  8. def error
  9. [__('Invalid password, it must contain at least 1 digit!')]
  10. end
  11. def self.applicable?
  12. Setting.get('password_need_digit').to_i == 1
  13. end
  14. end
  15. end