Sha256: c019b4388f7343302c9ad1f018ea8aff209316a674cd8aa224385678b49b1e77
Contents?: true
Size: 549 Bytes
Versions: 16
Compression:
Stored size: 549 Bytes
Contents
# Validate whether the default locale of a translated attribute is present # validates :content, presence_default_locale: true #------------------------------------------------------------------------------ class PresenceDefaultLocaleValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) attribute_locale = "#{attribute.to_s}_#{Account.current.preferred_default_locale}" if record.send(attribute_locale).blank? record.errors.add attribute_locale, I18n.t("errors.messages.blank") end end end
Version data entries
16 entries across 16 versions & 1 rubygems