Class: ChangeCaseOnlyValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ChangeCaseOnlyValidator
- Defined in:
- app/validators/change_case_only_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 6 |
# File 'app/validators/change_case_only_validator.rb', line 2 def validate_each(record, attribute, value) return if value.nil? || record.send(:"#{attribute}_was").nil? # i18n-tasks-use t("activerecord.errors.models.model_file.attributes.filename.case_change_only") record.errors.add attribute, :case_change_only if record.send(:"#{attribute}_changed?") && value.downcase == record.send(:"#{attribute}_was").downcase end |