8
9
10
11
12
13
14
15
16
17
|
# File 'app/models/system_settings/list_of_integers_validator.rb', line 8
def validate_each(record, attr_name, value)
came_from_user = :"#{attr_name}_came_from_user?"
raw_value = record.read_attribute_before_type_cast(attr_name) if record.respond_to?(came_from_user) && record.public_send(came_from_user)
raw_value ||= value
raw_value = value if record_attribute_changed_in_place?(record, attr_name)
record.errors.add(attr_name, :not_a_list_of_integers) unless matches_list_of_integers_regexp?(raw_value)
end
|