digit.rb 343 B

123456789101112131415161718
  1. class PasswordPolicy
  2. class Digit < PasswordPolicy::Backend
  3. NEED_DIGIT_REGEXP = /\d/.freeze
  4. def valid?
  5. @password.match? NEED_DIGIT_REGEXP
  6. end
  7. def error
  8. ['Invalid password, it must contain at least 1 digit!']
  9. end
  10. def self.applicable?
  11. Setting.get('password_need_digit').to_i == 1
  12. end
  13. end
  14. end