Class: RegexForms::ValidatePassword
- Inherits:
-
Object
- Object
- RegexForms::ValidatePassword
- Defined in:
- lib/regex_forms.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
Instance Method Summary collapse
-
#initialize(password) ⇒ ValidatePassword
constructor
A new instance of ValidatePassword.
- #validatePassword ⇒ Object
Constructor Details
#initialize(password) ⇒ ValidatePassword
Returns a new instance of ValidatePassword.
74 75 76 |
# File 'lib/regex_forms.rb', line 74 def initialize(password) @password = password end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
72 73 74 |
# File 'lib/regex_forms.rb', line 72 def password @password end |
Instance Method Details
#validatePassword ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/regex_forms.rb', line 78 def validatePassword return invalid_response("Password is nil, empty, or all zeros") if invalid_password regex = /\A.*(?=.*\d)(?=.*[!@#$%^&*]).*\z/ if regex.match(password) valid_response("Validated Password") else invalid_response("Must contain at least one digit and one special character: #{password}") end end |