Module: Validations::Predicates::Password::Methods
- Included in:
- Validations::Predicates::Password
- Defined in:
- lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/password.rb
Instance Method Summary collapse
Instance Method Details
#password?(value) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/password.rb', line 5 def password?(value) rules = [ %r{[A-Z]}, # at least 1 uppercase character (A-Z) %r{[a-z]}, # at least 1 lowercase character (a-z) %r{\d}, # at least 1 digit (0-9) %r{\W} # at least 1 special character (punctuation) ] matches = rules.inject(0) do |n, rule| value.match(rule) ? n + 1 : n end matches >= 3 end |