screen_name_validator: use non-deprecated syntax for adding errors to fields
This commit is contained in:
parent
b8666ca822
commit
96ccb09908
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue