Unverified Commit 9e784434 authored by Benjamin Wheeler's avatar Benjamin Wheeler Committed by GitHub

Merge pull request #3553 from benjiwheeler/join-flow-username-symbols

if username has spaces, provide validation message specifically mentioning that
parents d0ad7152 419f996f
......@@ -230,6 +230,7 @@
"registration.validationUsernameNotAllowed": "Username not allowed",
"registration.validationUsernameVulgar": "Hmm, that looks inappropriate",
"registration.validationUsernameInvalid": "Invalid username",
"registration.validationUsernameSpaces": "Usernames can't have spaces",
"registration.validationEmailInvalid": "Email doesn’t look right. Try another?",
"registration.waitForApproval": "Wait for Approval",
"registration.waitForApprovalDescription": "You can log into your Scratch Account now, but the features specific to Teachers are not yet available. Your information is being reviewed. Please be patient, the approval process can take up to one day. You will receive an email indicating your account has been upgraded once your account has been approved.",
......
......@@ -9,6 +9,8 @@ module.exports.validateUsernameLocally = username => {
return {valid: false, errMsgId: 'registration.validationUsernameMinLength'};
} else if (username.length > 20) {
return {valid: false, errMsgId: 'registration.validationUsernameMaxLength'};
} else if (/\s/i.test(username)) {
return {valid: false, errMsgId: 'registration.validationUsernameSpaces'};
} else if (!/^[\w-]+$/i.test(username)) {
return {valid: false, errMsgId: 'registration.validationUsernameRegexp'};
}
......
......@@ -33,7 +33,7 @@ describe('unit test lib/validate.js', () => {
test('validate username spaces not allowed', () => {
const response = validate.validateUsernameLocally('abc def');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameSpaces'});
});
test('validate username special chars not allowed', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment