2015-01-09 14:12:52 +01:00
|
|
|
class ScreenNameValidator < ActiveModel::EachValidator
|
2015-04-18 22:12:58 +02:00
|
|
|
FORBIDDEN_SCREEN_NAMES = %w(justask_admin retrospring_admin admin justask retrospring about public
|
2015-01-09 14:12:52 +01:00
|
|
|
notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
|
2015-02-16 18:59:59 +01:00
|
|
|
siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding
|
|
|
|
pixeidesu plxeldesu plxeidesu terms privacy)
|
2015-01-09 14:12:52 +01:00
|
|
|
|
|
|
|
def validate_each(record, attribute, value)
|
|
|
|
if FORBIDDEN_SCREEN_NAMES.include? value.downcase
|
|
|
|
record.errors[attribute] << "Thou shalt not use this username! Please choose another one."
|
|
|
|
end
|
|
|
|
end
|
2015-04-18 22:12:58 +02:00
|
|
|
end
|