Skip to content

Commit

Permalink
Address review comments about error message
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed May 23, 2024
1 parent e563e4a commit f027c6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions frontend/src/lib/components/Users/CreateUser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit f027c6b

Please sign in to comment.