Class: PasswordExclusivityValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PasswordExclusivityValidator
- Defined in:
- app/validators/password_exclusivity_validator.rb
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
Ensure password does not match username or email.
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
Ensure password does not match username or email.
5 6 7 8 9 |
# File 'app/validators/password_exclusivity_validator.rb', line 5 def validate_each(record, attribute, value) %w[username email].each do |field| record.errors.add(attribute, "can not match #{field}") if value.casecmp?(record.try(field)) end end |