Sha256: d1b2aaf8f2c3bb77e82825d25755cc144391815d97c3482211cb47c3c92d05c5
Contents?: true
Size: 651 Bytes
Versions: 1
Compression:
Stored size: 651 Bytes
Contents
module Antivirus module Validator class ProfanityFilterValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) record.errors[attribute] << message if value && profane?(value) end private def profane?(value) !!(value.downcase =~ Regexp.union(profane_words.map(&:downcase))) end def profane_words t('antivirus.profane_words', []) end def message t('antivirus.message', 'includes profane words.') end def t(key, default) value = I18n.t(key, default: '') value.presence || default end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
antivirus-0.0.2 | lib/antivirus/validator.rb |