[BB-1132] Decrease NAME_MIN_LENGTH to 1
This commit is contained in:
committed by
Agrendalath
parent
221153d864
commit
df14f5cdf6
@@ -11,7 +11,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
BIO_MAX_LENGTH = 300
|
||||
|
||||
# The minimum and maximum length for the name ("full name") account field
|
||||
NAME_MIN_LENGTH = 2
|
||||
NAME_MIN_LENGTH = 1
|
||||
NAME_MAX_LENGTH = 255
|
||||
|
||||
# The minimum and maximum length for the username account field
|
||||
|
||||
@@ -233,7 +233,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea
|
||||
""" Enforce minimum length for name. """
|
||||
if len(new_name) < NAME_MIN_LENGTH:
|
||||
raise serializers.ValidationError(
|
||||
u"The name field must be at least {} characters long.".format(NAME_MIN_LENGTH)
|
||||
u"The name field must be at least {} character long.".format(NAME_MIN_LENGTH)
|
||||
)
|
||||
return new_name
|
||||
|
||||
|
||||
@@ -552,7 +552,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
|
||||
("country", "GB", "XY", u'"XY" is not a valid choice.'),
|
||||
("year_of_birth", 2009, "not_an_int", u"A valid integer is required."),
|
||||
("name", "bob", "z" * 256, u"Ensure this value has at most 255 characters (it has 256)."),
|
||||
("name", u"ȻħȺɍłɇs", "z ", u"The name field must be at least 2 characters long."),
|
||||
("name", u"ȻħȺɍłɇs", " ", u"The name field must be at least 1 character long."),
|
||||
("goals", "Smell the roses"),
|
||||
("mailing_address", "Sesame Street"),
|
||||
# Note that we store the raw data, so it is up to client to escape the HTML.
|
||||
|
||||
@@ -658,12 +658,11 @@ class TestCreateAccountValidation(TestCase):
|
||||
|
||||
# Missing
|
||||
del params["name"]
|
||||
assert_name_error("Your legal name must be a minimum of two characters long")
|
||||
assert_name_error("Your legal name must be a minimum of one character long")
|
||||
|
||||
# Empty, too short
|
||||
for name in ["", "a"]:
|
||||
params["name"] = name
|
||||
assert_name_error("Your legal name must be a minimum of two characters long")
|
||||
params["name"] = ""
|
||||
assert_name_error("Your legal name must be a minimum of one character long")
|
||||
|
||||
def test_honor_code(self):
|
||||
params = dict(self.minimal_params)
|
||||
|
||||
Reference in New Issue
Block a user