Class: L10n::TranslationValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/l10n/translation_validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.kindObject



3
4
5
# File 'lib/l10n/translation_validator.rb', line 3

def self.kind
  :translation
end

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/l10n/translation_validator.rb', line 7

def validate_each(record, attribute, value)
  translations = record.public_send("#{attribute}_translations")
  I18n.available_language_codes.each do |language_code|
    if translations[language_code].blank?
      record.errors.add(record.class.translate_column_name("#{attribute}_t", language_code), options[:message] || :blank)
    end
  end
end