Class: ActiveModel::Validations::NgwordsValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::NgwordsValidator
- Defined in:
- lib/ngwords/validator.rb
Constant Summary collapse
- @@ngwords =
nil
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/ngwords/validator.rb', line 8 def validate_each(record, attribute, value) return if value.blank? if Moji.normalize_zen_han(value) =~ ngwords record.errors.add(attribute, I18n.t('activerecord.errors.messages.includes_ngwords', default: ' includes prohibited words.')) end end |