Skip to content

Commit 4159380

Browse files
authored
fix: email validation in input widget v2 (#40708)
## Description <ins>Problem</ins> Inbuilt email validation was not functioning correctly for all valid email formats (e.g. `[email protected]`), leading to incorrect validation failures in the Input widget. <ins>Root cause</ins> Outdated or overly restrictive email validation regex in `InputWidgetV2`. <ins>Solution</ins> This PR handles updating the email validation regex in `InputWidgetV2` to support modern and valid email formats. It also refactors and enhances the validation test suite to improve coverage across input types (NUMBER, TEXT, EMAIL, PASSWORD) and validation scenarios (required, custom, and regex), improving accuracy, readability, and maintainability. Fixes #`Issue Number` _or_ Fixes appsmithorg/appsmith-ee#7550 > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Input" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/15133467577> > Commit: 35d0614 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=15133467577&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Input` > Spec: > <hr>Tue, 20 May 2025 09:29:25 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved email validation to support a wider range of valid email formats. - **Tests** - Expanded and reorganized input validation tests to cover more input types and edge cases, ensuring more robust validation across NUMBER, TEXT, EMAIL, and PASSWORD fields. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 338357d commit 4159380

File tree

2 files changed

+395
-364
lines changed

2 files changed

+395
-364
lines changed

app/client/src/widgets/InputWidgetV2/widget/derived.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default {
7676
* https://stackoverflow.com/questions/15017052/understanding-email-validation-using-javascript
7777
* */
7878
const emailRegex = new RegExp(
79-
/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/,
79+
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
8080
);
8181

8282
if (!emailRegex.test(value)) {

0 commit comments

Comments
 (0)