Sha256: 4b753aed38d39cfe3a8730d27e95d079004ed92a004df4c48d129c8d97abdeb9
Contents?: true
Size: 443 Bytes
Versions: 8
Compression:
Stored size: 443 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) # rubocop:disable Rails/DeprecatedActiveModelErrorsMethods end end end
Version data entries
8 entries across 8 versions & 1 rubygems