class SerialTranslator::SerialTranslatorPresenceValidator

Public Instance Methods

kind() click to toggle source
# File lib/serial_translator/serial_translator_presence_validator.rb, line 11
def kind
  :presence
end
validate_each(record, attribute, _value) click to toggle source
# File lib/serial_translator/serial_translator_presence_validator.rb, line 3
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