module PasswordStrength

Attributes

enabled[RW]

You can disable PasswordStrength without having to change a single line of code. This is specially great on development environment.

Public Class Methods

test(username, password, options = {}) click to toggle source

Test the password strength by applying several rules. The username is required to match its substring in passwords.

strength = PasswordStrength.test("johndoe", "mypass")
strength.weak?
#=> true

You can provide an options hash.

strength = PasswordStrength.test("johndoe", "^Str0ng P4ssw0rd$", :exclude => /\s/)
strength.status
#=> :invalid

strength.invalid?
#=> true

You can also provide an array.

strength = PasswordStrength.test("johndoe", "^Str0ng P4ssw0rd$", :exclude => [" ", "asdf", "123"])
# File lib/password_strength.rb, line 31
def self.test(username, password, options = {})
  strength = Base.new(username, password, options)
  strength.test
  strength
end