From b342f32d97f30b9de2d9a325efaa4a3d7409f237 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sat, 13 Sep 2025 21:06:54 +0200 Subject: [PATCH] Simplify null checks in sendEmail validation logic --- src/sendEmail.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sendEmail.ts b/src/sendEmail.ts index a61783b..ce360a7 100644 --- a/src/sendEmail.ts +++ b/src/sendEmail.ts @@ -79,7 +79,7 @@ export const sendEmail = async ( throw new Error('Field "to" is required for sending emails') } - if (!emailData.subject || emailData.subject === null || !emailData.html || emailData.html === null) { + if (!emailData.subject || !emailData.html) { throw new Error('Fields "subject" and "html" are required when not using a template') } @@ -87,10 +87,10 @@ export const sendEmail = async ( if (emailData.to) { emailData.to = parseAndValidateEmails(emailData.to as string | string[]) } - if (emailData.cc && emailData.cc !== null) { + if (emailData.cc) { emailData.cc = parseAndValidateEmails(emailData.cc as string | string[]) } - if (emailData.bcc && emailData.bcc !== null) { + if (emailData.bcc) { emailData.bcc = parseAndValidateEmails(emailData.bcc as string | string[]) } @@ -108,4 +108,4 @@ export const sendEmail = async ( return email as unknown as T } -export default sendEmail \ No newline at end of file +export default sendEmail