i18n: Refactor, fix and clean up auth forms

This commit is contained in:
Michal Šmahel committed 2025-06-09 21:54:47 +02:00
1 parent 74915f6840
commit 00f3941ca6
24 files changed
+1899 -717

No files matched your search

+19 -21
View File
@@ -9,10 +9,9 @@ const nameSchema = joi
.trim()
.pattern(/^[\p{L}\p{M}''\- ]+$/u)
.messages({
"string.empty": "Name is required",
"string.max": "Name must be less than 50 characters",
"string.pattern.base":
"Name must contain only letters, spaces, apostrophes, or hyphens",
"string.empty": "auth.common.inputs.firstName.errors.empty",
"string.max": "auth.common.inputs.firstName.errors.length",
"string.pattern.base": "auth.common.inputs.firstName.errors.pattern",
});
const lastnameSchema = joi
@@ -21,10 +20,9 @@ const lastnameSchema = joi
.trim()
.pattern(/^[\p{L}\p{M}''\- ]+$/u)
.messages({
"string.empty": "Surname is required",
"string.max": "Surname must be less than 50 characters",
"string.pattern.base":
"Surname must contain only letters, spaces, apostrophes, or hyphens",
"string.empty": "auth.common.inputs.lastName.errors.empty",
"string.max": "auth.common.inputs.lastName.errors.length",
"string.pattern.base": "auth.common.inputs.lastName.errors.pattern",
});
const newPasswordSchema = joi
@@ -56,12 +54,12 @@ const newPasswordSchema = joi
return value;
})
.messages({
"string.empty": "Password is required",
"string.min": "Password must be at least 8 characters long",
uppercase: "Password must contain at least one uppercase letter",
lowercase: "Password must contain at least one lowercase letter",
number: "Password must contain at least one number",
special: "Password must contain at least one special character",
"string.empty": "auth.common.inputs.password.errors.empty",
"string.min": "auth.common.inputs.password.errors.length",
uppercase: "auth.common.inputs.password.errors.uppercase",
lowercase: "auth.common.inputs.password.errors.lowercase",
number: "auth.common.inputs.password.errors.number",
special: "auth.common.inputs.password.errors.special",
});
const newOrChangedCredentials = joi.object({
@@ -73,8 +71,8 @@ const newOrChangedCredentials = joi.object({
.email({ tlds: { allow: false } })
.lowercase()
.messages({
"string.empty": "authRegisterEmailRequired",
"string.email": "authRegisterEmailInvalid",
"string.empty": "auth.common.inputs.email.errors.empty",
"string.email": "auth.common.inputs.email.errors.invalid",
}),
password: newPasswordSchema,
newPassword: newPasswordSchema,
@@ -89,8 +87,8 @@ const newOrChangedCredentials = joi.object({
return value;
})
.messages({
"string.empty": "This field can't be empty",
different: "Passwords do not match",
"string.empty": "auth.common.inputs.passwordConfirm.errors.empty",
different: "auth.common.inputs.passwordConfirm.errors.different",
}),
role: joi.array(),
teamId: joi.string().allow("").optional(),
@@ -104,13 +102,13 @@ const loginCredentials = joi.object({
.email({ tlds: { allow: false } })
.lowercase()
.messages({
"string.empty": "authRegisterEmailRequired",
"string.email": "authRegisterEmailInvalid",
"string.empty": "auth.common.inputs.email.errors.empty",
"string.email": "auth.common.inputs.email.errors.invalid",
}),
password: joi
.string()
.messages({
"string.empty": "Please enter your password",
"string.empty": "auth.common.inputs.password.errors.empty",
}),
});