Fix codestyle in `ScreenNameValidator`
This commit is contained in:
parent
77c6dc7120
commit
1933aaac7f
|
@ -1,16 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ScreenNameValidator < ActiveModel::EachValidator
|
||||
FORBIDDEN_SCREEN_NAMES = %w(justask_admin retrospring_admin admin justask retrospring about public
|
||||
FORBIDDEN_SCREEN_NAMES = %w[justask_admin retrospring_admin admin justask retrospring about public
|
||||
notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
|
||||
siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding
|
||||
pixeidesu plxeldesu plxeidesu terms privacy linkfilter feedback)
|
||||
FORBIDDEN_SCREEN_NAME_REGEXPS = [/wreciap\z/i]
|
||||
pixeidesu plxeldesu plxeidesu terms privacy linkfilter feedback].freeze
|
||||
FORBIDDEN_SCREEN_NAME_REGEXPS = [/wreciap\z/i].freeze
|
||||
|
||||
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
|
||||
if FORBIDDEN_SCREEN_NAME_REGEXPS.any? { |regexp| value.downcase =~ regexp }
|
||||
record.errors[attribute] << "Registration is tempoarily disabled for new users."
|
||||
end
|
||||
record.errors[attribute] << "Thou shalt not use this username! Please choose another one." if FORBIDDEN_SCREEN_NAMES.include? value.downcase
|
||||
record.errors[attribute] << "Registration is tempoarily disabled for new users." if FORBIDDEN_SCREEN_NAME_REGEXPS.any? { |regexp| value.downcase =~ regexp }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue