Skip to content

[fix] send email validate address - allow address with .afrca domain#4827

Open
MarshallRJ wants to merge 2 commits intoshesha-io:releases/0.43from
MarshallRJ:fix-emailToValidAddress
Open

[fix] send email validate address - allow address with .afrca domain#4827
MarshallRJ wants to merge 2 commits intoshesha-io:releases/0.43from
MarshallRJ:fix-emailToValidAddress

Conversation

@MarshallRJ
Copy link
Copy Markdown

@MarshallRJ MarshallRJ commented Apr 17, 2026

We are unable to send emails to address with the .africa domina eg: rob@test.africa

We are unable to send emails to address with + in the mailbox eg: rob+dep@test.com

We added test for these and amended the isValidEmail check

Summary by CodeRabbit

  • Bug Fixes
    • Email validation now accepts the + character and allows longer TLDs; null/blank inputs are rejected.
  • Refactor
    • Email validation is faster/more efficient.
  • Behavior Change
    • Trimming-to-snake-case output was adjusted (result formatting may differ).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a5acafe9-7f15-4dc0-944b-da1be08783c4

📥 Commits

Reviewing files that changed from the base of the PR and between 233dde3 and 23cdefd.

⛔ Files ignored due to path filters (1)
  • shesha-core/test/Shesha.Tests/StringHelper/StringHelperIsValidEmailTests.cs is excluded by none and included by none
📒 Files selected for processing (1)
  • shesha-core/src/Shesha.Framework/Utilities/StringHelper.cs

Walkthrough

Single-file update to email validation and string utility methods: added a cached compiled email regex, return false for null/whitespace inputs, allow + in local-part, extend TLD length to {2,}, and changed SnakeCaseTrim() to return string.Join("_", parts) without additional .ToSnakeCase() post-processing.

Changes

Cohort / File(s) Summary
String Utility Methods
shesha-core/src/Shesha.Framework/Utilities/StringHelper.cs
Added a cached/compiled ValidEmailExpression and refactored IsValidEmail() to return false for null/whitespace and use ValidEmailExpression.IsMatch(inputEmail). Email regex now permits + in the local-part and uses TLD {2,}. SnakeCaseTrim() no longer calls .ToSnakeCase() on the joined result. Minor whitespace/line-ending normalization elsewhere in the file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I hopped through strings with gentle cheer,
Allowed a plus to linger near,
Trimmed white spaces, stitched snakes in line,
Compiled my pattern — oh, how fine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title mentions allowing .africa domain but doesn't clearly convey that the primary changes also include allowing plus signs in email addresses and refactoring email validation logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MarshallRJ
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@shesha-core/src/Shesha.Framework/Utilities/StringHelper.cs`:
- Around line 997-1017: The SnakeCaseTrim(string text, int length) overload
trims parts but returns string.Join("_", parts) which can leave double
underscores when parts become empty; update the return in SnakeCaseTrim(this
string text, int length) to normalize collapsed underscores (e.g., call
RemoveDoubleUnderscores() or ToSnakeCase()) to match the SnakeCaseTrim(string[]
parts, int length) behavior so both overloads produce identical snake-cased
output without consecutive underscores.
- Around line 867-875: IsValidEmail currently strips all internal whitespace
using Regex.Replace which can accept malformed addresses; change the
normalization to use inputEmail?.Trim() ?? "" (or remove normalization entirely)
in the IsValidEmail method, and make its regex a single static readonly Regex
(with RegexOptions.Compiled) instead of constructing a new Regex per call
(declare a new private static readonly Regex ValidEmailExpression and use it in
IsValidEmail). Also reconcile the two validators by updating the existing
EmailExpression / IsEmail to use the same pattern (or remove the duplicate
helper) so IsEmail and IsValidEmail share the canonical regex and behavior
(including allowing + and the updated TLD handling) to avoid divergent
validation paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: db80365a-1faf-4bf9-a781-fe377d4583a8

📥 Commits

Reviewing files that changed from the base of the PR and between afe1356 and 233dde3.

⛔ Files ignored due to path filters (1)
  • shesha-core/test/Shesha.Tests/StringHelper/StringHelperIsValidEmailTests.cs is excluded by none and included by none
📒 Files selected for processing (1)
  • shesha-core/src/Shesha.Framework/Utilities/StringHelper.cs

Comment thread shesha-core/src/Shesha.Framework/Utilities/StringHelper.cs
Comment thread shesha-core/src/Shesha.Framework/Utilities/StringHelper.cs
@MarshallRJ
Copy link
Copy Markdown
Author

@coderabbitai review changes

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

@MarshallRJ Sure! I'll review the changes now.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant