Sha256: 3af1c35d0a1f4ed546f87be12020f29032766166c0466517263e0a9f65c6e099
Contents?: true
Size: 384 Bytes
Versions: 7
Compression:
Stored size: 384 Bytes
Contents
# frozen_string_literal: true module EacRailsUtils class ImmutableValidator < ActiveModel::EachValidator DEFAULT_MESSAGE = 'cannot be changed' def validate_each(record, attribute, _value) return if record.new_record? return unless record.send("#{attribute}_changed?") record.errors[attribute] << (options[:message] || DEFAULT_MESSAGE) end end end
Version data entries
7 entries across 7 versions & 1 rubygems