models: fix deprecated errors[:base] << "message" calls.
Replace the idiom `errors[:base] << "message"` with `errors.add(:base, "message")`. The former is deprecated in Rails 6.1.
This commit is contained in:
@@ -2,10 +2,10 @@ class UserNameValidator < ActiveModel::EachValidator
|
||||
def validate_each(rec, attr, value)
|
||||
name = value
|
||||
|
||||
rec.errors[attr] << "already exists" if User.find_by_name(name).present?
|
||||
rec.errors[attr] << "must be 2 to 100 characters long" if !name.length.between?(2, 100)
|
||||
rec.errors[attr] << "cannot have whitespace or colons" if name =~ /[[:space:]]|:/
|
||||
rec.errors[attr] << "cannot begin or end with an underscore" if name =~ /\A_|_\z/
|
||||
rec.errors[attr] << "is not allowed" if name =~ Regexp.union(Danbooru.config.user_name_blacklist)
|
||||
rec.errors.add(attr, "already exists") if User.find_by_name(name).present?
|
||||
rec.errors.add(attr, "must be 2 to 100 characters long") if !name.length.between?(2, 100)
|
||||
rec.errors.add(attr, "cannot have whitespace or colons") if name =~ /[[:space:]]|:/
|
||||
rec.errors.add(attr, "cannot begin or end with an underscore") if name =~ /\A_|_\z/
|
||||
rec.errors.add(attr, "is not allowed") if name =~ Regexp.union(Danbooru.config.user_name_blacklist)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user