Sha256: cbed05fb1d755c0872de2266eb0accce0400baf781232e8766341c4a73b66270
Contents?: true
Size: 295 Bytes
Versions: 3
Compression:
Stored size: 295 Bytes
Contents
# frozen_string_literal: true class PersistedValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if (options[:allow_nil] && value.nil?) || value.try(:persisted?) record.errors.add(attribute, (options[:message] || "must be persisted")) end end
Version data entries
3 entries across 3 versions & 1 rubygems