retrospring/app/validators/screen_name_validator.rb

13 lines
681 B
Ruby
Raw Normal View History

class ScreenNameValidator < ActiveModel::EachValidator
2015-02-03 14:55:36 +01:00
FORBIDDEN_SCREEN_NAMES = %w(justask_admin retrospring_admin admin justask retrospring about public
notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
2015-01-13 13:23:12 +01:00
siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding
group settings search pixeidesu plxeldesu plxeidesu)
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
end