Sha256: 38ecf5f511d65cb4ad43d5f64700933f17774b305a8d48f67aef1713035e4b24
Contents?: true
Size: 614 Bytes
Versions: 5
Compression:
Stored size: 614 Bytes
Contents
if defined?(ActiveModel) module ActiveModel module Validations class ObscenityValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if options.present? && options.has_key?(:sanitize) object = record.respond_to?(:[]) ? record[attribute] : record.send(attribute) object = Obscenity.replacement(options[:replacement]).sanitize(object) else record.errors.add(attribute, options[:message] || 'cannot be profane') if Obscenity.profane?(value) end end end end end end
Version data entries
5 entries across 5 versions & 2 rubygems