Skip to content

Commit f027c6b

Browse files
committed
Address review comments about error message
1 parent e563e4a commit f027c6b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

frontend/src/lib/components/Users/CreateUser.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
name: z.string().trim().min(1, $t('register.name_missing')),
2828
email: z.string().trim()
2929
.min(1, $t('project_page.add_user.empty_user_field'))
30-
.refine((value) => isEmail(value) || (allowUsernames && usernameRe.test(value)), { message: $t('register.invalid_input') }),
30+
.refine((value) => isEmail(value) || (allowUsernames && usernameRe.test(value)), (value) => ({ message: isEmail(value) ? $t('register.invalid_email', { email: value }) : $t('register.invalid_username', {username: value}) })),
3131
password: passwordFormRules($t),
3232
score: z.number(),
3333
locale: z.string().trim().min(2).default(userLocale),
@@ -43,7 +43,7 @@
4343
$errors.email = [$t('register.account_exists')];
4444
}
4545
if (error.invalidInput) {
46-
$errors.email = [$t('register.invalid_input')];
46+
$errors.email = [$t('register.invalid_input', { username: $form.email })];
4747
}
4848
return;
4949
}

frontend/src/lib/i18n/locales/en.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia
225225
"shared_password_description": "For new users",
226226
"usernames": "Logins or emails (one per line)",
227227
"usernames_description": "This will be the **Send/Receive login** for new users",
228-
"invalid_username": "Invalid login/username: {username}. Can only use letters, numbers, and underscore (_) characters.",
228+
"invalid_username": "Invalid login/username: {username}. Only letters, numbers, and underscore (_) characters are allowed.",
229229
"empty_user_field": "Please enter email addresses and/or logins",
230230
"creator_must_have_email": "You must have an email address in order to create a project.",
231231
"members_added": "{addedCount} new {addedCount, plural, one {member was} other {members were}} added to project.",
@@ -389,7 +389,9 @@ If you don't see a dialog or already closed it, click the button below:",
389389
"register": {
390390
"title": "Register",
391391
"account_exists": "An account with this email already exists",
392-
"invalid_input": "Please specify an email address or a valid username",
392+
"invalid_email": "Invalid email address: {email}",
393+
"invalid_username": "Invalid login/username: {username}. Only letters, numbers, and underscore (_) characters are allowed.",
394+
"invalid_input": "Invalid email address or login/username: {username}. Only letters, numbers, and underscore (_) characters are allowed.",
393395
"button_register": "Register",
394396
"label_email": "Email",
395397
"label_email_or_username": "Email or login/username",

0 commit comments

Comments
 (0)