Sha256: 1624b73ff5bbe29676c62a596a4c5de3daea1063c473d1089b568af84271802d

Contents?: true

Size: 360 Bytes

Versions: 1

Compression:

Stored size: 360 Bytes

Contents

class SerialTranslator::SerialTranslatorPresenceValidator < ActiveModel::Validations::PresenceValidator
  def validate_each(record, attribute, _value)
    translations = record.__send__("#{attribute}_translations") || {}
    return if translations.values.any?(&:present?)
    record.errors.add_on_blank(attribute, options)
  end

  def kind; :presence end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
serial_translator-1.0.0 lib/serial_translator/serial_translator_presence_validator.rb