screen_name_validator: use non-deprecated syntax for adding errors to fields

This commit is contained in:
Georg Gadinger 2022-06-21 20:01:20 +02:00 committed by Karina Kwiatek
parent b8666ca822
commit 96ccb09908
1 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ class ScreenNameValidator < ActiveModel::EachValidator
FORBIDDEN_SCREEN_NAME_REGEXPS = [/wreciap\z/i].freeze FORBIDDEN_SCREEN_NAME_REGEXPS = [/wreciap\z/i].freeze
def validate_each(record, attribute, value) def validate_each(record, attribute, value)
record.errors[attribute] << "Thou shalt not use this username! Please choose another one." if FORBIDDEN_SCREEN_NAMES.include? value.downcase record.errors.add(attribute, message: "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 } record.errors.add(attribute, message: "Registration is tempoarily disabled for new users.") if FORBIDDEN_SCREEN_NAME_REGEXPS.any? { |regexp| value.downcase =~ regexp }
end end
end end