Skip to content

Commit 7d5fae3

Browse files
committed
fix(ht_email_inmemory): add sender email validation
- Added validation for sender email format. - Throws InvalidInputException on invalid format. - Improved input validation robustness.
1 parent f9bfd13 commit 7d5fae3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/src/ht_email_inmemory.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ class HtEmailInMemory implements HtEmailClient {
2323

2424
@override
2525
Future<void> sendTransactionalEmail({
26+
required String senderEmail,
2627
required String recipientEmail,
2728
required String templateId,
2829
required Map<String, dynamic> templateData,
2930
}) async {
3031
// Simulate input validation as per the interface contract.
32+
if (!_emailRegExp.hasMatch(senderEmail)) {
33+
throw InvalidInputException(
34+
'Invalid sender email format: $senderEmail',
35+
);
36+
}
3137
if (!_emailRegExp.hasMatch(recipientEmail)) {
3238
throw InvalidInputException(
3339
'Invalid recipient email format: $recipientEmail',
@@ -37,6 +43,7 @@ class HtEmailInMemory implements HtEmailClient {
3743
// Log the simulated email for debugging purposes.
3844
_log.info('''
3945
--- 📧 Simulating Email Send 📧 ---
46+
Sender: $senderEmail
4047
Recipient: $recipientEmail
4148
Template ID: $templateId
4249
Template Data: $templateData

0 commit comments

Comments
 (0)