From f027c6bcaef0507724b2517df1bc9d657f389387 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Thu, 23 May 2024 17:25:27 +0700 Subject: [PATCH] Address review comments about error message --- frontend/src/lib/components/Users/CreateUser.svelte | 4 ++-- frontend/src/lib/i18n/locales/en.json | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/Users/CreateUser.svelte b/frontend/src/lib/components/Users/CreateUser.svelte index 0d372c64f..fd9c6e1ee 100644 --- a/frontend/src/lib/components/Users/CreateUser.svelte +++ b/frontend/src/lib/components/Users/CreateUser.svelte @@ -27,7 +27,7 @@ name: z.string().trim().min(1, $t('register.name_missing')), email: z.string().trim() .min(1, $t('project_page.add_user.empty_user_field')) - .refine((value) => isEmail(value) || (allowUsernames && usernameRe.test(value)), { message: $t('register.invalid_input') }), + .refine((value) => isEmail(value) || (allowUsernames && usernameRe.test(value)), (value) => ({ message: isEmail(value) ? $t('register.invalid_email', { email: value }) : $t('register.invalid_username', {username: value}) })), password: passwordFormRules($t), score: z.number(), locale: z.string().trim().min(2).default(userLocale), @@ -43,7 +43,7 @@ $errors.email = [$t('register.account_exists')]; } if (error.invalidInput) { - $errors.email = [$t('register.invalid_input')]; + $errors.email = [$t('register.invalid_input', { username: $form.email })]; } return; } diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index aa08db832..d42455c10 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -225,7 +225,7 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia "shared_password_description": "For new users", "usernames": "Logins or emails (one per line)", "usernames_description": "This will be the **Send/Receive login** for new users", - "invalid_username": "Invalid login/username: {username}. Can only use letters, numbers, and underscore (_) characters.", + "invalid_username": "Invalid login/username: {username}. Only letters, numbers, and underscore (_) characters are allowed.", "empty_user_field": "Please enter email addresses and/or logins", "creator_must_have_email": "You must have an email address in order to create a project.", "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:", "register": { "title": "Register", "account_exists": "An account with this email already exists", - "invalid_input": "Please specify an email address or a valid username", + "invalid_email": "Invalid email address: {email}", + "invalid_username": "Invalid login/username: {username}. Only letters, numbers, and underscore (_) characters are allowed.", + "invalid_input": "Invalid email address or login/username: {username}. Only letters, numbers, and underscore (_) characters are allowed.", "button_register": "Register", "label_email": "Email", "label_email_or_username": "Email or login/username",