Sha256: 8fae3d544d51881aed1ae3adb907c30ffe513580403df1c7bbb7a657ecd5e0e9
Contents?: true
Size: 447 Bytes
Versions: 3
Compression:
Stored size: 447 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
3 entries across 3 versions & 1 rubygems