do not normalize name before validating

This commit is contained in:
r888888888
2017-03-06 16:54:24 -08:00
parent 3c581adbc3
commit 51c752be2f

View File

@@ -1,7 +1,5 @@
class UserNameValidator < ActiveModel::EachValidator
def validate_each(rec, attr, value)
name = User.normalize_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:]]|:/