refactor: Simplify client-side email validation

We don't need to implement custom check for lowercase, as it's
been already implemented in joi library. Also we don't need to
convert email to lowercase twice (via onChange and onInput event
handlers), onChange is completely sufficient and as it's just
before form validation, it's the better one.
This commit is contained in:
Michal Šmahel
2025-06-07 21:44:04 +02:00
parent c5efa71875
commit 3ac0eb2128
2 changed files with 1 additions and 8 deletions
+1 -7
View File
@@ -71,13 +71,7 @@ const credentials = joi.object({
.string()
.trim()
.email({ tlds: { allow: false } })
.custom((value, helpers) => {
const lowercasedValue = value.toLowerCase();
if (value !== lowercasedValue) {
return helpers.message("Email must be in lowercase");
}
return lowercasedValue;
})
.lowercase()
.messages({
"string.empty": "authRegisterEmailRequired",
"string.email": "authRegisterEmailInvalid",