Ngwords prevents prohibited words from being registered in your application. The prohibited word list can be set in the YAML data format. Ngwords currently only works with Rails.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install ngwords
1. Create your settings in
defaults: &defaults en: - shit - id password input ja: - 白痴 - ID パスワード 入力 development: <<: *defaults test: <<: *defaults production: <<: *defaults
en is a list of prohibited words for space-separated languages such as English. The block in
ja is for non-space delimited languages such as Japanese.
Note: To prevent data registration when all words are included, set prohibited words with a space delimiter like
id password input.
ngwords: true to your model's validates method
class Post < ApplicationRecord validates :title, presence: true, ngwords: true validates :body, ngwords: true end
Note: If you want to customize the error message, set your locale setting file (e.g.:
config/locales/ja.yml) as follows.
ja: activerecord: errors: messages: includes_ngwords: "は禁止単語を含んでいます。"
- Fork it ( https://github.com/chitamano/ngwords/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
The gem is available as open source under the terms of the MIT License.