21 lines
432 B
JavaScript
21 lines
432 B
JavaScript
const validateEmail = (email) => {
|
|
// Must be a string
|
|
if (typeof email !== "string") {
|
|
return false;
|
|
}
|
|
|
|
// Remove spaces
|
|
const trimmedEmail = email.trim();
|
|
|
|
// Basic email format validation
|
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
|
|
return emailRegex.test(trimmedEmail);
|
|
};
|
|
const normalizeEmail = (email) => {
|
|
return email.trim().toLowerCase();
|
|
};
|
|
|
|
module.exports = {
|
|
validateEmail, normalizeEmail
|
|
}; |