mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-23 12:12:21 -05:00
7 lines
336 B
Ruby
7 lines
336 B
Ruby
class ChangeCaseOnlyValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
return if value.nil? || record.send(:"#{attribute}_was").nil?
|
|
record.errors.add attribute, :case_change_only if record.send(:"#{attribute}_changed?") && value.downcase == record.send(:"#{attribute}_was").downcase
|
|
end
|
|
end
|