Sha256: e0eeb9dbecbbf6631f262d1ce7d1309845da280cdb81a43d4a614d9cdec98b83
Contents?: true
Size: 445 Bytes
Versions: 4
Compression:
Stored size: 445 Bytes
Contents
module SerialTranslator class SerialTranslatorPresenceValidator < ActiveModel::Validations::PresenceValidator def validate_each(record, attribute, _value) translations = record.__send__("#{attribute}_translations") || {} return if translations.values.any?(&:present?) if record.send(attribute).blank? record.errors.add(attribute, :blank, options) end end def kind :presence end end end
Version data entries
4 entries across 4 versions & 1 rubygems