max_length.rb 504 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class PasswordPolicy
  3. class MaxLength < PasswordPolicy::Backend
  4. MAX_LENGTH = 1_000
  5. def valid?
  6. self.class.valid? @password
  7. end
  8. def error
  9. self.class.error
  10. end
  11. def self.applicable?
  12. true
  13. end
  14. def self.valid?(input)
  15. input.length <= MAX_LENGTH
  16. end
  17. def self.error
  18. [__('Invalid password, it must be shorter than %s characters!'), MAX_LENGTH]
  19. end
  20. end
  21. end