Reputation: 1555
I have a field in my form, that should not accept some specific words(www, ftp, smtp, etc). Is there any validator that could make some kind of black listed words, that can not be written to db?
Upvotes: 2
Views: 809
Reputation: 1241
You should create your own black list validator. The syntax could be
validates :field, :black_list => {:file_path => "/path/to/words_file"}
Your validator will look to each word in the /path/to/words_file
file and add errors on your model if the attribute field
contains one black listed word.
Upvotes: 1
Reputation: 2013
validates :subdomain, :exclusion => { :in => %w(www ftp smtp) }
ref: rails guide
Upvotes: 4