mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-07 17:20:06 -05:00
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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user