2015-01-09 05:12:52 -08:00
|
|
|
class ScreenNameValidator < ActiveModel::EachValidator
|
2015-04-18 13:12:58 -07:00
|
|
|
FORBIDDEN_SCREEN_NAMES = %w(justask_admin retrospring_admin admin justask retrospring about public
|
2015-01-09 05:12:52 -08:00
|
|
|
notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
|
2015-02-16 09:59:59 -08:00
|
|
|
siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding
|
2022-01-22 12:29:30 -08:00
|
|
|
pixeidesu plxeldesu plxeidesu terms privacy linkfilter feedback)
|
2018-07-27 11:27:40 -07:00
|
|
|
FORBIDDEN_SCREEN_NAME_REGEXPS = [/wreciap\z/i]
|
2015-01-09 05:12:52 -08: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
|
2018-07-27 11:27:40 -07:00
|
|
|
if FORBIDDEN_SCREEN_NAME_REGEXPS.any? { |regexp| value.downcase =~ regexp }
|
|
|
|
record.errors[attribute] << "Registration is tempoarily disabled for new users."
|
|
|
|
end
|
2015-01-09 05:12:52 -08:00
|
|
|
end
|
2015-04-18 13:12:58 -07:00
|
|
|
end
|