From 8c03efbfc097426de105997bbe6ea814f4ac5aed Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 18 Sep 2025 16:52:33 +0200 Subject: [PATCH] implemented email format check --- src/lib/util.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/lib/util.ts diff --git a/src/lib/util.ts b/src/lib/util.ts new file mode 100644 index 0000000..b6600fa --- /dev/null +++ b/src/lib/util.ts @@ -0,0 +1,13 @@ + +function check_email_format(email: string) { + const trimmed = email.trim() + + if (trimmed.length > 254) return false + + const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/; + return emailRegex.test(trimmed) +} + +export default { + check_email_format, +}